Begin by defining an array of MenuItem configuration properties that describe each item in the MenuBar.
Next use the
method of the Event utility to instantiate the MenuBar as soon as the
page's DOM is available for scripting.
The "lazyload" property is set to "true" to help speed up the initial load time of the MenuBar instance by deferring the initialization and rendering of each submenu until just before it is initially made visible. The "itemdata" property is set to the array of MenuItem configuration properties; each item in the array will be used to add a new item to the MenuBar when it is rendered.
Often the first item in a menu bar has an icon as its label, but no text. It is easy to achieve this using CSS, while still ensuring the text of the MenuItem is available to users of a screen reader.
Start by wrapping the MenuItem's text label in an
<em> element. Next, give
<em> a fixed width, and set the "text-indent" property to a value that
pushes the text beyond the boundaries of element as defined by the width. Use the "overflow"
property to hide the text. Lastly, apply an image to the MenuItem instance via the
Copyright © 2009 Yahoo! Inc. All rights reserved.