How do I disable a Wijmo Menu item?
Is it possible to disable a Wijmo menu item?
I have the following fiddle, and I'd like to disable a menu option (either a branch or a leaf) if the user doesn't have a certain permission. I've tried setting the <li>
and the <a>
tags of the node to have the disabled
attribute. I've tried setting disabled='disabled'
and disabled='true'
and disabled=true
, but can't get the menu item to disable.
The API for the menu component doesn't seem to have a method to disable an item, so I'm assuming I would just disable the element in the DOM.
In my fiddle, there is a leaf (Politics -- the second node under the first parent Breaking News) that has a URL associated to it. I'd like to be able to disable this item.
I开发者_JAVA百科s it possible to disable a Wijmo menu item? If so, how?
Thank you in advance!
We have a disable option added to the root menu. I don't think that is what you want though. I would just do soemthing similar to Kevin's recommendation, but still use the disabled attr. Like so:
$("#flyoutmenu").wijmenu();
$("#flyoutmenu a[disabled]").parent().addClass("ui-state-disabled").end().click(function () {
return false;
});
You can also add a little CSS to make it look disabled. Here is the updated fiddle: http://jsfiddle.net/3CQGC/3/
Why can't you just not display the branch or leaf you'd like to disable?
All the items on the menu are hyperlinks, so you can't disable them.
OR there is the trick of:
<a href="#" onclick="return false" />
to make sure the link does nothing when you click on it.
精彩评论