Reputation: 20183
I am trying to bind this submit event from a form which not always be in Dom, so I trying with .on()
:
$('body').on("form","submit", function(e){})
but firebug logs:
$("body").on is not a function
[Parar en este error]$('body').on("form","submit", function(e){
tried also
$(document).on("form","submit", function(e){})
Upvotes: 2
Views: 4273
Reputation: 30012
If you are upgrading to jQuery 1.7, you can use on() by applying form
as a selector, like:
$('body').on("submit", "form", function(e){
Which will bind the submit
event to body
, but filtering it to form
which works the same way as the delegate
example below.
If you are using 1.4.2 or newer, you can use delegate() like this:
$('body').delegate("form", "submit", function(e){
Upvotes: 9