In this case, you raise an event submit:
$("form[data-remote].edit_item").submit();
With this, you attach a handler to the event submit:
$("form[data-remote].edit_item").submit(function() {
alert('goo');
});
In the second, you say “warning when an event occurs submit” ... you don’t say “hey, obey”, for this you still need to call .submit()or what is the shortcut for: .trigger("submit")... like this:
$("form[data-remote].edit_item").submit(function() {
alert('goo');
}).submit();
... but at this moment, why not just notify separately? eg:
$("form[data-remote].edit_item").submit();
alert('goo');
source
share