浏览 2926 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2007-11-25
dojo.require("dijit.Menu"); dojo.require("dijit.ColorPalette"); dojo.require("dijit._Calendar"); dojo.require("dojo.parser"); // scan page for widgets and instantiate them </script> <script language="Javascript" type="text/javascript"> dojo.addOnLoad(function() { // create a menu programmatically function fClick() {alert("clicked!")}; var prog_menu = new Array("prog_menu1","prog_menu2"); var pMenu = new dijit.Menu({targetNodeIds:prog_menu}); pMenu.addChild(new dijit.MenuItem({label:"Programmatic Context Menu", disabled:true})); pMenu.addChild(new dijit.MenuSeparator()); pMenu.addChild(new dijit.MenuItem({label:"Simple menu item", onClick:fClick})); pMenu.addChild(new dijit.MenuItem({label:"Another menu item", onClick:fClick})); pMenu.addChild(new dijit.MenuItem({label:"With an icon", iconClass:"dijitEditorIcon dijitEditorIconCut", onClick:fClick})); var mItem = new dijit.MenuItem({label:"dojo.event clicking"}); dojo.connect(mItem, "onClick", function(){alert("click! handler created via dojo.connect()")}); pMenu.addChild(mItem); var pSubMenu = new dijit.Menu({parentMenu:pMenu, id:"progSubMenu"}); pSubMenu.addChild(new dijit.MenuItem({label:"Submenu item", onClick:fClick})); pSubMenu.addChild(new dijit.MenuItem({label:"Submenu item", onClick:fClick})); pMenu.addChild(new dijit.PopupMenuItem({label:"Submenu", popup:pSubMenu, id:"progPopupMenuItem"})); pMenu.startup(); }); </script> <div id="prog_menu1" style="border:1px solid blue; padding:10px; margin:20px 0;"> This div has a programmatic context menu on it that's different to the page menu. </div> <div id="prog_menu2" style="border:1px solid blue; padding:10px; margin:20px 0;"> This div has a programmatic context menu on it that's different to the page menu. </div> 就如上边的.当在层prog_menu1,prog_menu2上右击,就会有menu出现,我想在menu中的一个子菜单中onclick,得到<div>层的id 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |