<scripttype="text/javascript">dojo.require("dijit.MenuBar");dojo.require("dijit.MenuBarItem");varpMenuBar;functionfClickItem(){alert("Clicked on first item")};functionfClickAnotherItem(){alert("Clicked on the second Item!")};dojo.addOnLoad(function(){pMenuBar=newdijit.MenuBar({id:"SampleMenu"});pMenuBar.addChild(newdijit.MenuBarItem({label:"MenuBarItem#1 ",disabled:true,onClick:fClickItem}));pMenuBar.addChild(newdijit.MenuBarItem({label:"MenubarItem#2 ",onClick:fClickAnotherItem}));pMenuBar.placeAt("wrapper");pMenuBar.startup();});</script>
<divid="wrapper"></div>
Creation from markup is more simpler and structured.