首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网络技术 > 网络基础 >

在Rails2中应用Jquery,Jrails是必须的么

2012-11-01 
在Rails2中使用Jquery,Jrails是必须的么?在Rails2中使用Jquery时Jrails是不是必须要用的。在Stackoverflow

在Rails2中使用Jquery,Jrails是必须的么?
在Rails2中使用Jquery时Jrails是不是必须要用的。在Stackoverflow上找到了一个相对全面的解答。

原文连接:http://stackoverflow.com/questions/5591289/is-jrails-a-must-for-rails-jquery

提问:Is jRails a must for Rails + jQuery?

The only reason jRails was written is because of the RJS features of Rails 2 -- the ability to write javascript templates on the server. Prototype is intrinsically linked to the RJS functionality of Rails, as all the helper methods for RJS would translate to Prototype calls. In Rails 3, that functionality has been deprecated in favor of using more unobtrusive javascript (UJS) techniques, so all the JS code stays on the client side. Thus, the reliance on Prototype is no longer an issue in Rails 3.

?

TL;DR

    Without jRails, all javascript generated server-side will translate in to prototype javascript calls on the client-side -- RJS template helper methods, link_to :method => :delete calls, etc.

    With jRails, all those server-side methods will translate in to jQuery calls client-side instead.

    See above; a Rails 2 app's server-side helpers that generate javascript will use jQuery instead of prototype.

    No. jRails only affects the javascript generated server-side.

    You can include and use jQuery in your app in the same way you would include any other javascript resource in Rails 2. Once jQUery is included, its no different to using it on plain HTML, so look at the jQuery UI tutorials on how to use the datepicker or selectable

Chris answered.

?

热点排行