Rails3中运用jquery

Rails3中使用jquery首先建立一个新项目,实际上有没有-J都无所谓view sourceprint?1rails new helloworld -

Rails3中使用jquery

首先建立一个新项目,实际上有没有-J都无所谓

view sourceprint?1rails new helloworld -J

然后,在项目的Gemfile中添加,

?

view sourceprint?1gem 'jquery-rails'

运行

?

?

view sourceprint?1bundle install

再运行

?

view sourceprint?1rails generate jquery:install

这时Prototype和相应JS就会被删除,而替换成JQuery的JS。

?

如果你要使用JQuery UI的话在上面命令后面加个 --ui就可以了。

这样你项目中的Prototype就被替换成JQuery了。