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.

Collapse mobile menu on menu click

Home › Forums › Older releases › 0.9.x › Collapse mobile menu on menu click

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #1354
    allegro44
    Participant

    I’m using the bootstrap Navbar add-on. In the mobile menu I would like the menu to collapse automatically when the user clicks on the sub-menu links. The menu is partially overlaying the content so this needs to disappear when users select a navigation link. Please advise. Thanks.

    #1673
    admin
    Keymaster

    You can achieve it like this – open “jquery.smartmenus.bootstrap.js” and find the following lines:

    			.bind({
    				// set/unset proper Bootstrap classes for some menu elements
    				...

    Then change them like this:

    			.bind({
    				'select.smapi': function(e, item) {
    					var $this = $(this),
    						obj = $this.data('smartmenus');
    					if (obj.isCollapsible()) {
    						$this.closest('.navbar').find('button.navbar-toggle').click();
    					}
    				},
    				// set/unset proper Bootstrap classes for some menu elements
    				...

    This will make sure each time a menu item is selected a click is simulated on the navbar toggle button which would collapse the navbar.

    #1674
    allegro44
    Participant

    Works perfectly! Thank you for your help.

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