RailsConfEurope: The One-Two Punch – JQuery with Rails
Next session wasThe One-Two Punch: jQuery with Rails by Yehuda Katz of EngineYard. Yehuda has done a lot of work of integrating the JQuery javascript library with Rails, so it becomes a viable alternative for Prototype (the default library in Rails).
JQuery is basically a simple javascript framework for getting dom elements and do some stuff with it. Core to this are CSS3 like selectors (e.g. div:not(#foo), div:contains(txt), div:empty, ) plus some own (e.g. div.has(p)). Some useful css2 like selectors (e.g. div[foo!=bar], checkt attribuut waarde). Some are pseudoselectors, but very useful and powerful.
The selectors return a jQuery object. The same functions can be applied to this object (if it is an element, array of elements etc.) -> this is not the case in Prototype.
JQuery has 5 parts: dom manipulation, events, ajax, effects, plugins.
Seems like a really nice library and a good alternative for prototype.js. The dom manipulation and ajax stuff seems a lot simpler and the plugins option is really nice.
The Rails helpers use a really nifty trick. They add a metadate attribute to the html element (e.g. an input) and then the Ajax javascript handler can access that (e.g. url, model id etc.)
Another interesting library that was mentioned was livequery. Have to look into that. Seems to be a set of Rails helpers.
Resources
Slides: will be available on the site












