Unobtrusive Javascript for Rails
CSS showed the benefits of separating documentation presentation from document content. Until now, however, it’s been awkward (though possible) to separate Javascript behavior from document content. The built-in helpers that come with Rails follow the prevailing standard of inline Javascript.
I haven’t tried it yet, but UJS (formerly known as Unobtrusive Javascript) looks to be a very interesting approach to the problem. Rather than inline javascript, UJS allows you to specify client-side behavior using CSS-style selectors and Ruby (using RJS ). UJS also patches up all of the existing Rails helpers to work unobtrusively, meaning that your markup will be easier to read and more compact.
Introducing Unobtrusive Javascript gives a good description of the motivation and technology behind the solution, which uses a Javascript library called event:Selectors to bind events to DOM nodes using CSS selectors.

