Datasheet
Figure 1-3
These categories are tightly coupled and a user interaction often triggers an exchange with a server
that leads to a modification in the document. To illustrate the point, you are invited to follow some
of the actions that are performed after the document is loaded. One of the functions called in
init is
initMenuBar(). Most of the instructions in this function are copied from examples coming with the
YUI. (Unlike most of the other modules that are nicely wrapped in classes that you just have to instanti-
ate, the menu bar module requires quite a few instances of copying and pasting JavaScript instructions.)
Among these instructions, the ones that operate the magic and bring the menu bar to life in the file
menubar.js are:
var oMenuBar = new YAHOO.widget.MenuBar(
“menubar”,
{ fixedcenter: false }
);
oMenuBar.render();
YAHOO.buzzWatch.menuBar = oMenuBar;
YAHOO.buzzWatch.menuGo = oMenuBar.getItem(1);
The first instruction creates a menu bar object. The second one, oMenuBar.render(), applies the
modifications needed to instantiate the menu bar in the HTML document. The first argument of the
YAHOO.widget.MenuBar constructor call, “menubar”, is the identifier of an element of the HTML
10
Chapter 1
04_087889 ch01.qxp 5/2/07 12:56 PM Page 10