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)
  • You must be logged in to reply to this topic.

Register

You will be emailed a link to set your password.

Login

Lost password?