Start a new discussion

To start a new discussion please visit the discussions section of the GitHub home page of the project.

Discussions on GitHub

You can also search our old self-hosted forums for any useful information below but please note that posting new content here is not possible any more.

Hide desktop sub menu on click

Home Forums Older releases 0.9.x Hide desktop sub menu on click

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #1411
    mbros
    Participant

    I’m trying to set up a menu that behaves like a desktop OS menu, where the user clicks on the menu item to both show and hide the sub menu.

    I’ve set “showOnClick:true”, and this gets the showing behavior right, but it won’t hide the sub menu when I click on it’s parent/originating menu item/link.

    I’m using version 0.9.7 with nothing much in the way of options. The parent menu items just need to show the sub menus, not link to pages. So right now the top-level items’ HTML just looks like (without the extra spaces):

    < li >< a href="#" >About
    #1763
    admin
    Keymaster

    Hi, you can use the following API tweak:

    $('#main-menu').bind('click.smapi', function(e, item) {
    	var $item = $(item),
    		level = $item.parent().parent().dataSM('level'),
    		$sub = $item.parent().dataSM('sub');
    	if (level == 1 && $sub && $sub.dataSM('shown-before') && $sub.is(':visible')) {
    		$(this).smartmenus('menuHideAll');
    		return false;
    	}
    });

    Let me know if you still have any troubles.

    Cheers!

    #1764
    mbros
    Participant

    This worked for me! Thanks!

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘0.9.x’ is closed to new topics and replies.