Skip to content

Commit 14b28d8

Browse files
Van MirandaJangoSteve
authored andcommitted
Use $.fn.prop instead of $.fn.attr for disabling/re-enabling form elements
1 parent 287b929 commit 14b28d8

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/rails.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,26 +178,26 @@
178178
/* Disables form elements:
179179
- Caches element value in 'ujs:enable-with' data store
180180
- Replaces element text with value of 'data-disable-with' attribute
181-
- Adds disabled=disabled attribute
181+
- Sets disabled property to true
182182
*/
183183
disableFormElements: function(form) {
184184
form.find(rails.disableSelector).each(function() {
185185
var element = $(this), method = element.is('button') ? 'html' : 'val';
186186
element.data('ujs:enable-with', element[method]());
187187
element[method](element.data('disable-with'));
188-
element.attr('disabled', 'disabled');
188+
element.prop('disabled', true);
189189
});
190190
},
191191

192192
/* Re-enables disabled form elements:
193193
- Replaces element text with cached value from 'ujs:enable-with' data store (created in `disableFormElements`)
194-
- Removes disabled attribute
194+
- Sets disabled property to false
195195
*/
196196
enableFormElements: function(form) {
197197
form.find(rails.enableSelector).each(function() {
198198
var element = $(this), method = element.is('button') ? 'html' : 'val';
199199
if (element.data('ujs:enable-with')) element[method](element.data('ujs:enable-with'));
200-
element.removeAttr('disabled');
200+
element.prop('disabled', false);
201201
});
202202
},
203203

0 commit comments

Comments
 (0)