Search code examples
jqueryruby-on-railsujs

Rebind js to dynamically inserted :remote forms in rails


I'm using the standard jquery-rails unobtrusive approach in rails 3.2.

It works great if you have a form on the page with :remote => true. But what if you have an ajax action insert a new form on the page. The ajax binding doesn't seem to get reattached.

Is there some way to tell rails UJS to "rebind" to all the remote forms on the page?

Btw, this is the same for link_to :remote etc also. Thanks!


Solution

  • Nevermind - the rails UJS stuff was working correctly, reattaching etc. It was my own click event to the submit button that had to be reattached. :) Whoops!