I am trying to get this to work by following the manual at:
http://net.tutsplus.com/tutorials/javascript-ajax/using-unobtrusive-javascript-and-ajax-with-rails-3/
and railscast at
http://railscasts.com/episodes/205-unobtrusive-javascript
.. in both cases I have the same problem. The controller does not display the .js template (it returns to .html) because the request header does not request javascript as it should.
I am using jquery ujs from github and jquery 1.4.4
The "data-remote = true" attribute is passed to the form as intended. But for some reason this does not change the request.
If I switch to prototype.js, it works (with prototype.js and rails.js by default from rails).
I am using rails 3.0.0
Any suggestions appreciated.
Having lost a day ...: - (
I found that when you create a new Rails 3 application, the rails.js file is created in the public / javascripts folder, as well as all the other .js files that you see in the Rails 2 project.
rails.js contains all unobtrusive handlers. By default, Rails assumes that you are using Prototype.js.
For jQuery, replace the rails.js file with https://github.com/rails/jquery-ujs
The following link helped me: http://www.simonecarletti.com/blog/2010/06/unobtrusive-javascript-in-rails-3/
The βcurrentβ best way to handle this is to add this puppy to your gemfile.
https://github.com/indirect/jquery-rails
run
bundle install
then
rails generate jquery:install #--ui to enable jQuery UI --version to install specific version of JQuery (default is 1.4.2)
then you are all set up - it overwrites rails.js by default when the generator starts.
I had similar problems. Then I decided that with the Ajax problem, I should start with something very simple. So I started with This