Rails的未来&Javascript [英] Rails future & Javascript

查看:41
本文介绍了Rails的未来&Javascript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

David H.H. 最近宣布 jquery 将成为 Rails 3.1 的默认设置,Prototype helpers/RJS 将成为 gem.

David H.H. announced recently that jquery is going to be the default in Rails 3.1, and that Prototype helpers / RJS are going into a gem.

这对未来意味着什么?我们是否应该逐渐忘记诸如 javascript 助手、RJS 以及 Rails 的所有这些有趣部分之类的东西?并开始使用 jquery/json 进行编码?

What does that mean for the future? Should we progressively forget about things like javascript helpers, RJS, and all these fun parts of rails? And start coding with jquery/json in mind?

我一点也不反对,但我不得不承认我发现 RJS 使用起来真的很有趣......

I'm not against that at all, but I have to admit I find RJS really fun to use...

推荐答案

是的,不引人注目的 JavaScript 赢了.现在很多人直接在 ERB 模板中编写 JS/jQuery 代码.用部分替换某些 DOM 节点的 jQuery 代码仅比等效的 RJS 代码稍长.关于 JS 助手,用不显眼的 JS 代码替换它们应该很容易.检查如何在 中处理 data-remotejQuery Rails 驱动程序.

Yes, unobtrusive JavaScript has won. Many people write now directly JS / jQuery code in ERB templates. jQuery code to replace some DOM node with a partial is only slightly longer than equivalent RJS code. Regarding JS helpers, it should be quite easy to replace all of them with unobtrusive JS code. Check how data-remote is handled in jQuery Rails driver.

这种趋势是有道理的,因为 Web 应用程序有越来越多的 JS 代码无法用 RJS 编写.使用两种语言比使用三种语言要好.

This trend makes sense because web apps have more and more JS code which cannot be written in RJS. It is better to use two languages than three.

如果您不喜欢 JavaScript 语法,请查看 CoffeeScript.肯定会比 RJS 更受欢迎.

If you don't like JavaScript syntax then check out CoffeeScript. Which will be definitely more popular than RJS.

长期的未来可能属于像 SproutCore 这样的纯 JS 框架.服务器端将只处理 JSON 数据.然而,这些新技术只会在新应用中使用.通常将现有应用程序升级到新模型没有意义.

Long term future probably belongs to pure JS frameworks like SproutCore. Server side will process only JSON data. However these new techniques will be used only in new apps. Generally it doesn't make sense to upgrade existing apps to the new model.

这篇关于Rails的未来&Javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆