This topic contains 7 replies, has 3 voices, and was last updated by tbloomfield 7 years ago.
Viewing 8 posts - 1 through 8 (of 8 total)
Viewing 8 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic.
jQuery UI Widgets › Forums › 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 7 years ago.
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 Stoev
http://www.jqwidgets.com/
jQWidgets Team
OK, 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 Stoev
http://www.jqwidgets.com
jQWidgets Team
No 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 applications
It 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,
Tom
I 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
Tom
I found the solution. A second line of code is required.
$("#jqxMenu").jqxMenu('disable', 'item', true);
$('#item').click(function (e) {e.preventDefault();});
Thank you,
Tom
You must be logged in to reply to this topic.