js">
With that you??™re ready to bring your help sidebar to life.
Bringing Help to Life
As they say on MTV Cribs, this is where the magic happens. Now you need to add the
JavaScript behavior layer that will turn your basic help system into a dynamic contextual
sidebar. There is, in fact, very little JavaScript required to get you off the ground, which is
indicative of a solid design. If you let all the other parts of the application handle the jobs,
they should; then JavaScript just needs to be the behavioral glue to connect events on the
page to actions.
Building the Help Controller
To help you manage the code you need to implement the help sidebar and wrap it up in an
object. Because there is only one help sidebar per page, you can represent the help with a
single Help object. Open up public/javascripts/application.js to start writing the help
controller. You??™ll start with the basic open and close functionality:
var Help = {
open : function() {
$(document.body).addClassName('with-help');
},
close : function() {
$(document.body).removeClassName('with-help');
}
};
As mentioned before, to open and close the sidebar you simply need to add and remove
the with-help class on the body. Next you need to add a method that requests the help page
via an Ajax request and updates the help element with the content.
Pages:
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276