I have a function that I'm using to prevent multiple postbacks of a form:
var submitted = false;
$(function() {
$('form').bind('submit', function(e) {
if (!submitted && CanSubmit(e)) {
submitted = true;
return true;
} else {
return false;
}
});
});
In the CanSubmit
method, I need to interrogate the button that was clicked to determine whether I should allow the submit or not.
Note that I can't bind to specific click events - see this previous question for more details.
In Firefox, I can use e.originalEvent.explicitOriginalTarget
, but this is apparently not available in IE.
How can I get this value from the e
parameter in a cross-browser way?
Actually you could just replace $('form').bind('submit'
with $(':submit').bind('click'
and your code would work just as well (and you could use this
to see what was clicked).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With