SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 266 | Next

Jonathan Snook, Aaron Gustafson, Stuart Langridge, and Dan Webb

"Accelerated DOM Scripting with Ajax, APIs, and Libraries"

Updater('help', url, {
method: 'get',
onComplete: callback.bind(this)
});
}
};
The new openWith() method does exactly this, so now the skeleton controller object is
essentially complete. The next step is to wire it to the help links on the page, which is where
Low Pro comes in very handy.
Adding Behaviors
You can think of LowPro??™s Event.addBehavior() method as the equivalent of CSS, but for
behavior instead of style (a behavior sheet, if you like). In fact, the Event.addBehavior() usage
feels very similar to CSS in that it uses an extended form of CSS selectors to select elements
and events to apply behavior to. A typical call might look like this:
CHAPTER 9 n A DYNAMIC HELP SYSTEM 198
Event.addBehavior({
'a.product:click' : function() {
// when a elements with the class 'product' are clicked
// the code within this function will run
},
'div.description:mouseover' : function() {
// when divs with the class 'description' are moused over
// this function will run
}
});
You can call Event.addBehavior() as many times as you like and it will stack the behaviors
onto the elements automatically. Also, by default it will try to reapply its behaviors after every
Ajax request to ensure that any new content will have the behaviors applied to it. To hook up
the help controller to the help links on the page, place this in application.js:
Event.addBehavior({
'a[rel=help]:click' : function() {
Help.


Pages:
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6