Created
June 14, 2013 09:36
-
-
Save kezabelle/5780669 to your computer and use it in GitHub Desktop.
Reminder to self about disabling submits ... built to work with Django's jQuery version (1.4.2) so passing in the selector as part of the live arguments doesn't work :\
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var disable_elements = function(evt) { | |
// `this` is the form being submitted, in the current context ... | |
$(this) | |
.find('input[type="submit"], button, a.button') | |
.addClass('disabled') | |
.attr('readonly', 'readonly') | |
.attr('disabled', 'disabled') | |
.css({opacity: 0.5}); | |
// note: the css and disabled parts may need removing, depending | |
// on needs (ie: the css could be set on the `disabled` class) | |
// and the disabled bit may not work if relying upon the value | |
// in the GET/POST data. | |
}; | |
$('form').live('submit', disable_elements); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment