2

I hope you forgive me if I'm a little confused about this.

Jrails rewrites all the helper methods for rjs otherwise in prototype.

Jquery-rails overrides rails.js (so I taught the rjs helpers as well, but I see it's not) and the rest of the libraries in jquery instead of prototype.

Does it means that with just Jquery-rails I can't use rjs at all? Then do these gems work well together and let me completely forget prototype? Is there any disadvantage in using them together?

I read some complaining about the fact that jrails uses jq 1.5 and now there is 1.8, but jquery-rails gives me the last version (is there retro compatibility?), but how will this affect my development (using both the gems together)? I mean Have you got some examples of jquery-ui plugins I can't use, or I could have problems with latest versions?

Any help is appreciated.

Don't get me wrong, I'm not against prototype, just I keep on having conflicts over conflicts using both of them, and if I have to choose I pick Jquery.

ecoologic
  • 10,202
  • 3
  • 62
  • 66

2 Answers2

2

Yes, RJS requires jrails. Otherwise RJS generates prototype code. I just started using jrails and jquery-rails together and they work fine. I have to use jrails because my app has many RJS files.

In general, people who switched to jQuery write pure JavaScript code. They do not use RJS at all so jrails is not needed. Instead of RJS, ERB templates are used. E.g.

$('#foo').html("<%= escape_javascript(render "bar") %>"); 
Greg Dan
  • 6,198
  • 3
  • 33
  • 53
  • Yes I see a lot of this but I'd rather use rjs, looks much more clear, are you on rails 3? – ecoologic Mar 07 '11 at 23:38
  • I migrate my app to Rails 3 right now. Because RJS is loosing popularity I am going to use pure JS. I am also considering CoffeeScript, which is the newest trend last few months. – Greg Dan Mar 08 '11 at 07:21
1

Rails has the concept of a "javascript driver", which can be replaced with any javascript library. By dafault it uses prototype, but if you install jquery-rails, it removes the JS driver for prototype, and adds the jQuery driver.

So you can still run rjs with jQuery, as the driver is different, and will output jQuery commands, rather than prototype.

About the jQuery version, you're confusing jQuery with jQueryUI. The last version of jQuery is 1.5.1 (and I think jQuery-rails has 1.5), and the latest of jQueryUI is 1.8.10. jQuery UI is an extension of jQuery, which includes mouse interaction, more effects, themes and other goodies.

If you're new to jQuery, I strongly suggest you to read jQuery in Action. It's an amazing introduction to jQuery and jQueryUI.... definitely worth every penny.

Augusto
  • 28,839
  • 5
  • 58
  • 88
  • thanks, you're right, I got confused here http://stackoverflow.com/questions/1193119/jrails-alternative, strange nobody said anything about jquery version... – ecoologic Mar 08 '11 at 00:02