views:

15

answers:

0

I have a Rails 3 application that needs to use both Prototype and JQuery libraries. Now I am having problems when it comes to making different kinds of remote calls. I am able to do a remote_function call and return RJS and that works just fine. But, on another page I want to do a form_for :remote => true, but that fails - it just submits like a normal form. It seems like the JQuery is not handling the :remote => true stuff like its supposed to. I checked that the HTML is correct, that I have the correct JQuery version of rails.js, and that I have included the jquery libraries correctly and they are being loaded. One thing I noticed is that this alleged remote call has a content type of HTML instead of JS. That doesnt seem right to me, because the previous remote_function call had a content type of JS.

So my questions are:

  1. Am I missing something to make Rails use JQuery? Other than having the correct rails.js and including the jquery libraries, and adding the jQuery.noConflict() bits, do I need to install a gem or add some special lines to some config file somewhere?

  2. Should a form_for :remote => true call have a of content type JS or HTML?

  3. What is a form_for :remote => true call expecting to get back? Is it just looking for a good or bad status, or can I pass things back like RJS used to allow (like DOM changes, or effects)?

  4. I want to use the proper JQuery callbacks instead of RJS, how/what should I respond with? I'm confused about .js.rjs vs .js.erb, and how the data or DOM changes will get back to the page so that the JQuery callbacks can do something useful with them.