tags:

views:

276

answers:

2

We have a case where we only know the icon for a menu item at runtime. I know there is a iconClass parameter for a diji.MenuItem, but this is of little help unless we dynamically add CSS rules at runtime with dojox.html.insertCssRule - there must be a better way!

Here is an example of what we are trying to do:

pMenu = new dijit.Menu({
    targetNodeIds: ["NEW_APP"],
    leftClickToOpen: true
});

pMenu.popupDelay = 100;

pMenu.addChild(new dijit.PopupMenuItem({
    label: "clocks",
    iconSrc: "image/clocks.png",
    onClick: dojo.hitch(core.editor, core.editor.createNewApp)
}));
+1  A: 

Sure, there's a better way although not ideal, something like:

myMenuItem.iconNode.style.cssText = "background-image: url(...); width: 16px, height: 16px";

Bill Keese
+1  A: 

http://robrobbins.info/?p=372

Starmonkey