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
  • 69,856
  • 92
  • 277
  • 407

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
  • 113,627
  • 57
  • 144
  • 179
  • 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,713
  • 18
  • 66
  • 96
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,132
  • 14
  • 32