I want to disable a form submit button after it's clicked to prevent the form being submitted multiple times. I use the following code to disable the button and add a class that makes it appear disabled:
$("form button.primaryAction").click(function() {
$(this).prop("disabled", true).addClass('disabledBtn');
return true;
});
It works fine in IE and Firefox, but in Chrome 17 the form doesn't get submitted. I guess I could replace the code above with:
$("form button.primaryAction").click(function() {
$(this).prop("disabled", true).addClass('disabledBtn');
var form = // how can I get a reference to the form from the button 'this' ?
form.submit();
return false;
});
But as you can see I'm not sure how to get a reference to the form from inside the click handler.