2

Can the new prototype-rails gem for Rails 3.1 which allows RJS and prototype support also be used with JQuery-UJS to allow JQuery to be used with RJS that is JS templates and its helpers?

To confirm : I dont wish to use prototype I want JQuery to work with JS templates under 3.1.

Rob W
  • 341,306
  • 83
  • 791
  • 678

1 Answers1

0

Are you trying to say that you want to use prototype as well as jquery in rails project? If you insist then I would like to ask why, because both 'try' to achieve similar results. Why would you like to carry two bazookas to kill a single person... ;)

Still if you insist, they conflict if used together. I would suggest that don't include the javascript libraries in your layout file(application.html.erb) and include them separately in individual pages (depending on your choice for different pages), or controller specific layouts, using some code in application.html.erb, or any other way you deem fit. But to warn you - that is ugly!

amit_saxena
  • 7,450
  • 5
  • 49
  • 64
  • you can use it when you use the jQuery.conflict method but still no reason to use them both tho :P – Michael Koper May 22 '11 at 17:42
  • No I want to use JQuery but with JS templates, however, i believe RJS template functionality which isn't in Rails 3.1 is now in the prototype-rails gem, with prototype. I don't think JQuery-rails supports it on its own. –  May 22 '11 at 19:08
  • I think that RJS had been deprecated long back. Maybe it's a good time to refactor your code. Probably there is a jrails plugin to do what you intend to do: https://github.com/aaronchi/jrails/ – amit_saxena May 22 '11 at 19:24
  • You may find this discussion useful: http://stackoverflow.com/questions/5591289/is-jrails-a-must-for-rails-jquery – amit_saxena May 22 '11 at 19:37
  • RJS is supported however it has been separated from the core and is now a gem. The reason for this is so there is a upgrade path to 3.1 however its just not that clear when you add jquery into the equation. jrails wasn't needed in 3.0 to get this to work. I wish prototype-rails was separated into two gems prototype gem and a RJS gem or jquery-rails to include RJS functionality. –  May 22 '11 at 19:42