I am using Ruby on Rails 3.0.7 and I am migrating from Prototype to jQuery 1.6.1.
In my application I have a lot of input forms that make use of the remote tag in order to submit data using JavaScript:
# A form example in my application
<%= form_for(@user, :remote => true) do |f| %>
...
<% end %>
To fix this problem, in my app/views/application.html.erb file, I tried to change the code from this:
<%= javascript_include_tag :defaults, 'jquery-1.6.1.min' %>
to this:
<%= javascript_include_tag 'jquery-1.6.1.min', 'application' %>
However, the remote tag doesn’t work anymore with my forms (which is normal behavior since RoR use custom Prototype helper methods).
Is there an “easy” way to handle forms using JavaScript without Prototype and to avoid the above problem with the remote tag? If so, what do I have to do?
In the case, I must use Prototype to “solve”\”support” this problem, can I “delete”\”not load” in my public/javascript folder some of the following files?
application.js
controls.js
dragdrop.js
effects.js
jquery-1.6.1.min.js
prototype.js
rails.js
You need to tell Rails to use jQuery.
Add
gem jquery-railsto your Gemfile, and runrails g jquery:install.See the documentation for more information.