Skip to content

Instantly share code, notes, and snippets.

@mattparker
Created May 18, 2010 12:02
Show Gist options
  • Save mattparker/404914 to your computer and use it in GitHub Desktop.
Save mattparker/404914 to your computer and use it in GitHub Desktop.
var menuitems = [ {text:"item 1", url: "www.1.com"}, {text:"item 2", url: "www.1.com"}, {text:"item 3", url: "www.1.com"} ];
oMenu = new YAHOO.widget.Menu( "amenu", {
fixedcenter: true,
lazyload: true,
autosubmenudisplay: true
});
oMenu.addItems(menuitems);
oMenu.render("mymenu");
oMenu.show();
// Adds submenus to existing menu items
var addSubMenus = function (ev, aArgs) {
var oMenuItem = aArgs[1];
if (oMenuItem && !oMenuItem.cfg.getProperty("submenu") ) {
oMenuItem.cfg.setProperty( "submenu", { id: "sub" + oMenuItem.id, itemdata: menuitems});
oMenuItem.cfg.getProperty("submenu").mouseOverEvent.subscribe(addSubMenus);
oMenuItem.cfg.getProperty("submenu").show();
}
};
oMenu.mouseOverEvent.subscribe( addSubMenus );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment