views:

46

answers:

1

As a new comer to writing front-end views with Rails, I'm a bit confused as to when I should be using rjs templates versus when I should be writing my own JavaScript to handle events/DHTML. Is there some rules you avid Rails developers follow for when something is too complex or not possible with RJS and you just write the JavaScript yourself and have Rails load it?

What's the best practice here?

+4  A: 

I would avoid using RJS in principal unless you're developing against Rails 3 which supports unobtrusive javascript via HTML5 data attributes. Separation of javascript behaviour from presentation, which makes projects much more maintainable, is not possible with RJS in Rails 2 as it renders everything inline.

Bayard Randel