rails / jquery-ujs

Ruby on Rails unobtrusive scripting adapter for jQuery
MIT License
2.6k stars 508 forks source link

late bound forms #330

Open house9 opened 11 years ago

house9 commented 11 years ago

I have a rails form with remote => true (renders as data-remote="true"), normally rails jquery-ujs would modify this form to submit using ajax request - however my form is getting appended to the DOM based on user action and jquery-ujs appears to fire during document loading only - leaving my form as a non-ajax form

any ideas how I can get jquery-ujs to activate my late bound form?

looking through the source code:

worst case I can just manually code up my ajax calls for the late bound forms, that code is rather trivial, just not as simple as remote=>true

wondering if I am missing something and this is actually easy to do?

eddietejeda commented 11 years ago

+1

sfsekaran commented 10 years ago

+1

lucasmazza commented 10 years ago

@house9 @eddietejeda @sfsekaran is this still an issue for anyone? Currently jquery-ujs binds all events to the document element to support late bound elements through event delegation, so this should work out of the box for any HTML appended to the document after page load.

rafaelfranca commented 10 years ago

I had this issue once but it was because my form was inside another one with the remote=true attribute

sfsekaran commented 10 years ago

Context: I used the master version of jquery-ujs as of 6 days ago, with jQuery 1.10.1.

I'll be checking this again soon, and I'll report back.

sfsekaran commented 10 years ago

@lucasmazza Nevermind. For some reason, it's working again and honestly I'm not sure what I changed to fix it. I'll be back if something like this crops up again.