Thursday, September 17, 2009

jQuery disable button intercepts Request Object

Scenario: Hijack all my save buttons via the script below to override the value, from Save to Saving...., and then also disabling the button so they cannot hit it 1000 times.

$(document).ready(function() {
form.find(':submit').each(function() {
$(this).attr("disabled", "disabled").val("Saving....");
});
});

The Issue: I have several submit type buttons on the page, like Save, Sand and Proceed, Delete, etc, so I use the Request.Form object to see what button was pressed to decide what to do. Well, the disable of the button by jQuery removes it from the Reuquest stream, even though it is only disabled after the click event has occurred, how strange.

The Solution: I don't know what the solution is other than removing the disable as below. Any ideas?
$(document).ready(function() {
form.find(':submit').each(function() {
$(this).val("Saving....");
});
});

No comments:

Post a Comment