Suppose I have a form with id 'edit-resource' that will appear later in a modal dialog.
I attach a listener to the document like so, such that it will capture the event no matter how many times the modal form is posted back and replaced.
$(document).on('submit', '#edit-resource', function(e) {
//breakpoint
//ajax request with new FormData
return false; //cancel submit
});
When I submit the form, the event handler runs as expected, but by the time the breakpoint is hit... the post has already hit the server (which also has a breakpoint in place). Submit events are supposed to be cancelable (i.e. by returning false), but you can't cancel such an event if it's already hit the server by the first line of the handler. What is causing this issue?