Summary
Keywords
Full Transcript
Link for all dot net and sql server video tutorial playlists https://www.youtube.com/user/kudvenkat/playlists?sort=dd&view=1 Link for slides, code samples and text version of the video http://csharp-video-tutorials.blogspot.com/2015/07/jquery-menu-widget.html Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help. https://www.youtube.com/channel/UC7sEwIXM_YfAMyonQCrGfWA/?sub_confirmation=1 In this vide we will discuss jquery menu widget with examples 2 simple steps to get the jQuery menu widget on a page Step 1 : Create an HTML structure with parent/child relationship. The most commonly used element is the unordered list. To disable a menu item add ui-state-disabled class to that list item element. <ul id="menu"> <li>USA <ul> <li>Virginia</li> <li>Maryland</li> </ul> </li> <li>India <ul> <li>AP</li> <li class="ui-state-disabled">MP</li> <li>Karnataka <ul> <li>Bangalore</li> <li>Mangalore</li> <li>Mysore</li> </ul> </li> </ul> </li> <li>UK</li> <li>Australia</li> </ul> Step 2 : Find the unordered list element in the DOM and call menu() function $('#menu').menu(); To control the width, set the preferred with in the .ui-menu class. This class is applied to the unordered list by jquery ui. You can see this using the browser developer tools. <style> .ui-menu{ width:150px } </style> Please note : Another way you can control the width of the menu widget is by placing it as a child element in another element and setting the width of the parent element. <div style="width:150px"> Menu HTML here </div> You can add an icon to a menu item, by applying class names. For the list of icons provided by jQuery http://api.jqueryui.com/theming/icons/ <ul id="menu"> <li><span class="ui-icon ui-icon-flag"></span>USA <ul> <li>Virginia</li> <li>Maryland</li> </ul> </li> ... </ul> To associate a different icon to a submenu, use icons option $('#menu').menu({ icons: { submenu: 'ui-icon-circle-arrow-e' } }); To disable the menu, set disabled option to true $(document).ready(function () { $('#menu').menu({ disabled: true }); }); To get the selected item text, use the select event $('#menu').menu({ select: function (event, ui) { alert(ui.item.text()); } });
