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)
}));
Sure, there’s a better way although not ideal, something like:
myMenuItem.iconNode.style.cssText =
"background-image: url(...); width: 16px, height: 16px";