Yahoo! Developer Network Home - Help

Site Search (YDN & YUIBlog):

# YUI Library Examples: Menu Family: Website Left Nav With Submenus Built From Markup

# Menu Family: Website Left Nav With Submenus Built From Markup

This example demonstrates how to create a traditional, two-column page layout (using Grids) with a set of fly-out menu navigation in the left column.

View example in new window.

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 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.

/* Initialize and render the Menu when its elements are ready to be scripted. */ YAHOO.util.Event.onContentReady("productsandservices", function () { /* Instantiate a Menu: The first argument passed to the constructor is the id of the element in the page representing the Menu; the second is an object literal of configuration properties. */ var oMenu = new YAHOO.widget.Menu("productsandservices", { position: "static", hidedelay: 750, lazyload: true }); /* Call the "render" method with no arguments since the markup for this Menu instance is already exists in the page. */ oMenu.render(); });

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. Lastly, 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.

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.

#productsandservices { position: static; }

### Menu Family Examples:

- Basic Menu From Markup
- Basic Menu From JavaScript
- Grouped Menu Items Using Markup
- Grouped Menu Items Using JavaScript
- Grouped Menu Items With Titles From Markup
- Grouped Menu Items With Titles From JavaScript
- Multi-tiered Menu From Markup
- Multi-tiered Menu From JavaScript
- Handling Menu Click Events
- Listening For Menu Events
- MenuItem Configuration Properties
- Setting Menu Configuration Properties At Runtime
- Website Left Nav With Submenus Built From Markup
- Website Left Nav With Submenus From JavaScript
- Website Top Nav With Submenus Built From Markup
- Website Top Nav With Submenus From JavaScript
- Website Left Nav Using Animation With Submenus Built From Markup
- Website Left Nav Using Animation With Submenus From JavaScript
- Website Top Nav Using Animation With Submenus Built From Markup
- Website Top Nav Using Animation With Submenus From JavaScript
- Context Menu
- Adding A Context Menu To A Table
- Adding A Context Menu To A TreeView
- OS-Style Programs Menu
- Application Menubar
- Implementing ARIA Roles and States with Menu
- Context Menu Integration (included with examples for DataTable Control (beta))
- Menu Buttons (included with examples for Button Control)
- Split Buttons (included with examples for Button Control)
- Color Picker Button (included with examples for Button Control)
- Fixed Width Menu Button (included with examples for Button Control)
- Slider Button (included with examples for Button Control)
- Using the ProfilerViewer API while Profiling the YUI Menu Control (included with examples for ProfilerViewer Control (beta))

### More Menu Family Resources:

- User's Guide (external)
- API Documentation
- Cheat Sheet PDF (external)

Copyright © 2008 Yahoo! Inc. All rights reserved.

Privacy Policy - Terms of Service - Copyright Policy - Job Openings