jQuery UI Widgets › Forums › General Discussions › Navigation › Menu, Context Menu › Disable menu item
Tagged: JavaScript Menu, jQuery Menu, jqxMenu, Menu
This topic contains 7 replies, has 3 voices, and was last updated by tbloomfield 9 years, 2 months ago.
-
AuthorDisable menu item Posts
-
I couldn’t figure this out with the documentation….
…how do I disable a specific menu item in a menu (possibly inside a submenu)?Hi uuf6429,
To disable a menu item, you can use this:
$("#jqxMenu").jqxMenu('disable', 'item', true);
The ‘item’ is the id of the Menu Item’s LI. The last parameter is the disable/enable param.
Here’s the definition of the LI tag.
<li id="item"><a href="#RIA">Rich Internet applications</a></li>
Hope this helps you.
Best Regards,
Peter Stoevhttp://www.jqwidgets.com/
jQWidgets TeamOK, doesn’t seem too difficult. Is there any other way without having to specify an ID? Because my current app relies on known-position elements rather than ids (eg; ‘ul li:eq(5)’).
The method currently works only with Ids, but we will consider enhancing it in the further versions. Thank you for the nice idea and also for the feedback regarding the splitter’s post.
Best Wishes,
Peter Stoevhttp://www.jqwidgets.com
jQWidgets TeamNo problem. 🙂
Hello, the code recommended above doesn’t seem to work completely.
jquery code:
$(“#jqxMenu”).jqxMenu(‘disable’, ‘item’, true);
HTML code:
<li id=”item”>Rich Internet applicationsIt correctly applies the disabled style and doesn’t show submenus. That’s good. But, if the href is replaced with a URL , then clicking on the disabled menu item will actually go to the specified URL.
Any fixes for this?
Thank you,
TomI apologize about the previous post — it did not display correctly. The problem I found is that when the href refers to a URL, clicking on the disabled menu item will take the user to the URL, even though the menu item is disabled.
Thank you
TomI found the solution. A second line of code is required.
$("#jqxMenu").jqxMenu('disable', 'item', true); $('#item').click(function (e) {e.preventDefault();});Thank you,
Tom -
AuthorPosts
You must be logged in to reply to this topic.