submit event does not fire if submit initiated programmatically
That's because you shouldn't just use the submit
function, but trigger
the submit like:
$("#MyForm").trigger('submit');
Browsers don't fire the form's onsubmit
handler when you manually call form.submit()
.
jQuery also mimicks used to mimick that (see this "wontfix" "bug" report).
See also:
- Should jQuery's $(form).submit(); not trigger onSubmit within the form tag?
- JQuery: on submit doesn't work