Skip to content

Instantly share code, notes, and snippets.

@kezabelle
Created June 14, 2013 09:36
Show Gist options
  • Save kezabelle/5780669 to your computer and use it in GitHub Desktop.
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 :\
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