Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between jquery-rails & jquery-ujs

I have googled around a bit, but haven't been able to figure out what the exact difference between the two is. From the jquery-rails read me (https://github.com/indirect/jquery-rails) it seems that jquery-ujs complements it, but I'm not sure why/how.

Would appreciate it if someone could break this down to me.

Thanks.

like image 343
gmoniey Avatar asked Feb 04 '12 00:02

gmoniey


People also ask

Does rails use jQuery?

The jquery-rails gem contains all 3 jQuery versions. You can use jQuery 1, 2, and 3 by requiring jquery, jquery2, and jquery3 on application.

What is jQuery ujs?

jquery-ujs is a script, originally created for Ruby on Rails, to simplify common JavaScript actions and make it easier to execute RESTful actions through links. Even though it was created for Rails, it works perfectly with Laravel.


1 Answers

jquery-ujs is the unobtrusive implementation to allow you to use jQuery in a Rails app. Simply speaking, it's just a single rails.js. To use it, you have to get jQuery and setup your Rails app.

jquery-rails is the gem to do this for you, it bundles (in its own vendor/assets directory) the most recent jQuery, jQuery-UI and jquery-ujs lib. I suggest you use it directly.

Update: you can checkout the vendor/assets/javascripts directory here:

https://github.com/rails/jquery-rails/tree/master/vendor/assets/javascripts

Under it sit the most recent jquery, jquery-ui and jquery_ujs(identical to the rails.js in jquery-urj project).

like image 72
James Chen Avatar answered Oct 07 '22 23:10

James Chen