Permalink
Browse files

Use $.fn.prop instead of $.fn.attr for disabling/re-enabling form ele…

…ments
  • Loading branch information...
1 parent 287b929 commit 14b28d88741e4156e60aba7a5493c70e36cb2694 Van Miranda committed with JangoSteve Oct 7, 2011
Showing with 4 additions and 4 deletions.
  1. +4 −4 src/rails.js
View
@@ -178,26 +178,26 @@
/* Disables form elements:
- Caches element value in 'ujs:enable-with' data store
- Replaces element text with value of 'data-disable-with' attribute
- - Adds disabled=disabled attribute
+ - Sets disabled property to true
*/
disableFormElements: function(form) {
form.find(rails.disableSelector).each(function() {
var element = $(this), method = element.is('button') ? 'html' : 'val';
element.data('ujs:enable-with', element[method]());
element[method](element.data('disable-with'));
- element.attr('disabled', 'disabled');
+ element.prop('disabled', true);
});
},
/* Re-enables disabled form elements:
- Replaces element text with cached value from 'ujs:enable-with' data store (created in `disableFormElements`)
- - Removes disabled attribute
+ - Sets disabled property to false
*/
enableFormElements: function(form) {
form.find(rails.enableSelector).each(function() {
var element = $(this), method = element.is('button') ? 'html' : 'val';
if (element.data('ujs:enable-with')) element[method](element.data('ujs:enable-with'));
- element.removeAttr('disabled');
+ element.prop('disabled', false);
});
},

0 comments on commit 14b28d8

Please sign in to comment.