Rails 3.0 beta & JS Helpers with jQuery

The Rails 3.0 Blog Release Notes say:

"Unobtrusive JavaScript helpers with drivers for Prototype, jQuery"

So how do I configure Rails 3 to use jQuery? Still loading all Prototype libraries by default.

I realized that Rails 3 has built-in functionality similar to the jRails plugin, but maybe I don't understand :)

Also, as a bonus question, if I use Prototype, is there a way to get Rails to download mini versions and even better is a single JS file to shorten HTTP requests?

Thanks.

+5
source share
6 answers

Rails 3, -J:

$ rails app_name -J

, Prototype. , , - jquery.js public/javascripts. , jQuery rails.js. :

http://github.com/rails/jquery-ujs/blob/master/src/rails.js

EDIT: , . :

<%= javascript_include_tag "jquery", "rails" %>

, !

+2

Unobtrusive JS PrototypeHelper, .. , :remote => true form_for , , rails.js submit click xhr.

jquery, ujs- ( ) jquery ujs, - rails 3. .

+1

Google

javascript js . , , .

+1

Rails 3, .

, , public/javascript. : prototype.js, effects.js, dragdrop.js controls.js( ). js , .

, js .

0

, ajax 3.

, , , data-remote=true, :remote => true - link_to, link_to_remote rails 3, onclick , Ajax.

, Ajax Rails 3? , javascript-, , , data-remote=true, - , Rails ( , ), , , jquery, - .

javascript github, , :

prototype

jQuery

, jquery public/javascripts jquery, javascript_include_tag :all javascript_include_tag ( )

0

you can see this article: http://flow.handle.it/past/2010/2/9/jquery_in_rails/ . It explains how to work with unobtrusive JS and jQuery.

Hope this helps.

0
source

All Articles