The help sidebar feature is very
simple, but with large projects the gains in maintainability become even more apparent. You
can separate a very complex JavaScript project up into several behaviors that are then glued
into the document via Event.addBehavior(). If the HTML structure changes, it??™s trivial to
adapt your scripts.
When It Comes to Ajax, Simple Is Best
There are many methods of communication between JavaScript and the server side. Of
course, originally, there was the X in Ajax: XML. Since then JSON, RJS, and plain HTML have
emerged as other formats, as well as a whole raft of more niche technologies. The rule of
thumb here is to go for the simplest method possible to get the job done. In most cases you
don??™t even need anything as rich as JSON; most of the time you can just send a request, return
a chunk of update HTML and replace the relevant part of the document with it. Prototype??™s
Ajax.Updater makes this method extremely simple.
In this project, Ajax.Updater is used to great effect. There??™s no need to wrap the Ajax
responses up in JSON and then write code to unpack it and handle it on the client side, so the
returned HTML is simply placed into the sidebar