1

I'm doing like this:

$('.myforms').ajaxForm();

after I add some more forms to the html which have this .myforms class assigned, so I have to call the $('.myforms').ajaxForm() again

is it possible to register the ajaxForm live ?

Omu
  • 67,351
  • 88
  • 268
  • 400

3 Answers3

2

checkout the Live Query plugin. It allows you to simulate the .live() but extends the behaviour to DOM elements, not just events.

lomaxx
  • 109,635
  • 56
  • 141
  • 178
  • I would like some peace of code from this plugin that would do this, without using the plugin – Omu Dec 15 '10 at 08:05
1

Not with jQuery's live(), but you could monitor the form for changes to the DOM and trigger ajaxForm() from there. See this thread

Community
  • 1
  • 1
Jake
  • 12,014
  • 15
  • 61
  • 93
1

You do not need to use jQuery live, all you need to do is put the ajaxForm code inside a function and then in the ajax success you just call the function again to rebind the new form in the view.

    function bindSubmitNewPost()  {

     var options = { 
        target:        '#new-post-message-1',  
        beforeSubmit:  showRequest, 
        success:       showResponse  

       }; 


    $('.FormNewPost').ajaxForm(options);  
}
jason
  • 1,084
  • 13
  • 30