Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inserting data-remote form via JavaScript in a Rails App, ujs not catching remote

I have a simple form that is being appended to a container:

<form action="/something" data-remote="true" method="post">
  <input type="submit" />
</form>

My understanding was that rails_ujs.js captures all submit events, so I wouldn't need to reattach any events when inserting new forms. However, this form is not being picked up as a remote form. Even when I put a debugger in rails_ujs.js on the general submit event this form is not firing that event. All forms rendered server-side trigger it no problem.

Did I miss something about having to attach an event to dynamically inserted form?

like image 719
bcardarella Avatar asked May 17 '13 16:05

bcardarella


1 Answers

It turns out I was rendering a form within a form and that was causing the issue. I'm an idiot :p

like image 176
bcardarella Avatar answered Sep 22 '22 04:09

bcardarella