YUI recommends YUI3.
YUI 2 has been deprecated since 2011. This site acts as an archive for files and documentation.
This documentation is no longer maintained.
This example demonstrates how to create a traditional, two-column page layout (using Grids) with an set of animated fly-out menu navigation in the left column. The left navigation is created using a Menu instance that is constructed using existing markup and enables the user to navigate to different landing pages for each Yahoo! product category. If JavaScript is enabled, submenus are appended to the items in the Menu, allowing the user to skip the product landing pages and proceed directly to a given property.
Begin by placing the markup for the two-column Grid on the page (this example uses the Grids Preset Template 1, 160px left). Next add the Menu markup for the root Menu instance to the left column of the grid.
Use the onContentReady
method of the Event utility to instantiate the Menu as soon as
its markup is available for scripting.
This Menu instance makes use of several configuration properties. Setting the "autosubmenudisplay" configuration property to "true" modifies its default behavior so that mousing over any item in the Menu automatically triggers the display of its submenu. The "hidedelay" configuration property is set to "750" so each submenu automatically hides 750ms after the user's mouse has left the menu. The "lazyload" property is set to "true" to help speed up the initial load time of the Menu instance by deferring the initialization and rendering of each submenu until just before it is initially made visible. Lastly, the effect configuration property is set to use the pre-canned FADE ContainerEffect instance bundled with the Container Core package to animate each submenu's opacity as it is shown and hidden.
Submenus are added to each item in the Menu by subscribing to the "beforeRender" event and setting the "submenu" configuration property of each MenuBarItem instance to an object literal containing the necessary data to create the submenu.
Finally, it is necessary to set the "position" CSS property of the root Menu
instance's element (<div id="#productsandservices">
) to
"static" to match that of the "position" configuration property.
All YUI 2.x users should review the YUI 2.8.2 security bulletin, which discusses a vulnerability present in YUI 2.4.0-2.8.1.
Copyright © 2013 Yahoo! Inc. All rights reserved.