jQuery submit is not catching submit event after ajax loading of content -


i load content popup jquery ajax load function , use submit function in load functions callback function, reason event not fired @ all. (i use jquery jquery-1.3.2.min.js)

$('.popup-container').load(url, function(){      /** stuff here */     $("form").submit(function() {          alert("form submitted!");                return false;     }); }); 

update

as of jquery 1.7, .live() method is deprecated. removed in jquery 1.9. use .on() attach event handlers. users of older versions of jquery should use .delegate() in preference .live().


original answer

you can fix using jquery method live(). using live() submit() has been added jquery 1.4 should update. here video tutorial on using live() submit().

when using live function code should this:

$("form").live('submit' , function() {      alert("form submitted!");            return false; });  $('.popup-container').load(url); 

Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -