Respect regular onsubmit handlers from jQuery.submit
Posted
by orip
on Stack Overflow
See other posts from Stack Overflow
or by orip
Published on 2010-05-11T08:31:30Z
Indexed on
2010/05/11
8:34 UTC
Read the original article
Hit count: 350
I want a jQuery form submit handler to respect any previous submit handlers, including ones added with onsubmit
.
I'm trying to detect the previous handler's return value but can't seem to do it:
<form><input type="submit" /></form>
<script type="text/javascript">
$('form')[0].onsubmit = function() { return false; }; // called first
$('form').submit(function(e) {
console.log(e.result); // undefined
console.log(e.isDefaultPrevented()); // false
console.log(e.isPropagationStopped()); // false
console.log(e.isImmediatePropagationStopped()); // false
});
</script>
Is there a way to do this?
© Stack Overflow or respective owner