Why onClick event not work on dojo MenuItem? -


i'm studying dojo 1.10.4, problem onclick event not work on dijit/menuitem. tried on other item widgets dijit/checkedmenuitem , dijit/radiomenuitem, none of click events work, , api docs didn't give tips it.

at last, found works if it's contained in dijit/menubar. should item widgets contained in dijit/menubar or dijit/menu? how events processed on dojo widgets?

for example:

<html> <head> <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/dojo/1.10.4/dijit/themes/claro/claro.css">  <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/dojo.js"     data-dojo-config="async:true,parseonload: true"></script> <script>   require(["dojo/parser"],function(parser){     parser.parse();   }); </script> </head> <body class="claro"> <div data-dojo-type="dijit/menubar" > <div data-dojo-type="dijit/menuitem" onclick="alert();">it works</div> </div>  <div data-dojo-type="dijit/menuitem" onclick="alert();">it     doesn't work</div> </body> </html> 

in case menuitem needs containerwidget menu or menubar. add item child :

require([          "dojo/dom",          "dijit/menuitem",          "dijit/dropdownmenu",          "dijit/form/dropdownbutton"          ],          function(dom,menuitem,dropdownmenu,dropdownbutton){            var mymenu = new dropdownmenu();             var menuitem1 = new menuitem({                             id:"m1",                             label:"show m1",                             onclick:function(){                              //do want here                              }                             });            mymenu.addchild(menuitem1);            }); 

studying might understand how works. http://dojotoolkit.org/reference-guide/1.10/dijit/dropdownmenu.html#dijit-dropdownmenu

regards


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -