popupMenuItem programmatic instantiation

View: New views
1 Messages — Rating Filter:   Alert me  

popupMenuItem programmatic instantiation

by Werner Punz-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello everyone I am currently banging my head against the popupMenuItem
programmatic instantiation.

While it is perfectly clear for a simple menu

<div id="menu">
</div>

var myMenu = new dijit.Menu({}, dojo.byId("menu"));

myMenu.add(new dijit.MenuItem({label:"itemlabel"});

myMenu.startup();

it is not entirely clear how to do that with an integrated popup menu item

<div id="menu">
<div id="popup">
        <span>popup</span>
        <div id="menu2">
        </div>
</div>
</div>

var myMenu = new dijit.Menu({}, dojo.byId("menu"));
var popup = new dijit.PopupMenuItem({},dojo.byId("popup"));
var menu2 = new dijit.Menu({},dojo.byId("menu2"));

myMenu.add(new dijit.MenuItem({label:"itemlabel"});
myMenu,add(popup);...

...


myMenu.startup();

produces a javascript error at
new dijit.PopupMenuItem({},dojo.byId("popup")); node not defined in dojo.js

if I leave the dojo.byId out then I get an empty menu

It does not matter whether I add the menu2 explicetly to the popup or
not, the error occurs earlier.

Does anyone have a working example on how to initialize the popup menu
on a menu programmatically?

Werner

_______________________________________________
FAQ: http://dojotoolkit.org/support/faq
Book: http://dojotoolkit.org/docs/book
Forums: http://dojotoolkit.org/forum
Dojo-interest@...
http://turtle.dojotoolkit.org/mailman/listinfo/dojo-interest