I used dijit/MenuItem in a popup menu for the JS Canvas object. When user right click the Canvas, I want to show the menu and disable some items based on the location that user selected. Hence, I code in the onmousedonw event of the Canvas to disable the item.
Everything works fine except that when I right click and the menuitem change from enabled to disabled, the item in the menu is still showing as normal state until I move mouse over it and then it shows gray as disabled. Is there a way that I can somehow “refresh” the menuitem after changing the disabled state so that it will be shown as grayed out immediately when the menu show?
HTML for the menu
<ul dojoType="dijit/Menu" id="menu" style="display: none;border-radius:3px;">
<div dojoType="dijit/MenuItem" id="Popup_Cut"><span>Cut</span></div></ul>
JS for the disable
function handleMouseDown(event) {
if(...)
dijit.byId("Popup_Cut").disabled = true;
}
Instead of using the property
disabled, use thesetmethod instead:Had the same problem, and this worked for me.
More info on
set:http://dojotoolkit.org/reference-guide/1.8/dijit/info.html#set-and-get