开发者

In real life, is it common for rails app's to not use the built in ajax features?

Is it common practice for people to NOT use rail's built in support for ajax? Or is it very flexible and it can really help speed things up and there is no need to go cus开发者_如何学运维tom?


If by ajax you mean ajax view helpers, in rails 3 they are implemented quite well, and there really isn't a reason not to use them. If you mean RJS, it is a much faster way to get stuff done, but if you want to build highly dynamic and responsive interfaces, there is no shortcut to writing the javascript yourself.


Rails 2 was heavily tied to Prototype and was pretty obtrusive; it seemed a lot of people didn't use. Rails 3 is far more unobtrusive and framework-agnostic, and I expect it will be used a lot more.


Let me put it this way..

Using built in ajax functionalities will will save lot of your time and get your app up an running with no-time. But the problem is once your app starts growing and when you need more and more cool ajax features, its hard to manage.

Another thing is, If you are working on a team and there are UI designers to implement UI. sometimes they find it difficult to deal with built-in rails ajax functions. As they prefer go with pure Ajax framework and HTML.

Basic concept here is to let the UI designers to implement a user friendly interface while rails supports back-end features

** I really like the rails3 approach of Unobtrusive javascripts. which makes the clear separation of java scripts and server code

So as a sum up - Its all depending on the requirement. If you are looking at a small scale project with defined ajax functionalities you may go with default rails ajax support.

But if your app will grow and if you want to continuously implement your user experience its a good idea to have your own custom ajax implementations up on proven framework like jquery

cheers

sameera


I am not sure what you mean by built-in support for ajax. Because Rails has very good support for Prototype and jQuery.

But in rails 3 there is (good) push towards unobtrusive javascript, and that is indeed imho what most people do.

If you are talking about rjs, generating javascript with ruby code: that is imho best avoided. Sometimes it is good to get you started, and doing things unobtrusively is sometimes a bit harder at first, but it is generally much better.

The rant against rjs: it is not unobtrusive, you mix two languages, it only works for very straightforward cases (granted most cases). But because you can't do everything with rjs, there is bound to be a need to let some 'real' javascript slip in. At first i really liked rjs: one language to do everything in. Until you discover the boundaries, and then you are stuck.

So i would suggest, for anybody new beginning in Rails: skip rjs. It will help you in the long run. Do javascript unobtrusively.

It is the same division in CSS: you want all your stylistic definitions separate from the content. Well, actually in js you want the same: you want your behaviour separated from the content. This makes for very clean HTML, clean CSS and clean js.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜