How do I drop the entire menu by selecting an item from it?

Home Forums Latest release 1.1.x + Bootstrap 4 addon How do I drop the entire menu by selecting an item from it?

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #8302
    genivaldo
    Participant

    I would like that when selecting a menu item on the mobile platform (mobile, tablet), the entire menu would be closed, having to click the button to open it again.

    #8303
    admin
    Keymaster

    Hi, you could use something like this:

    $(function() {
      // SmartMenus jQuery - collapse mobile navbar on menu item select
      $('.navbar-nav').on('select.smapi', function(e) {
      	if ($(this).hasClass('sm-collapsible')) {
      		$('.navbar-toggler')[0].click();
      	}
      });
    });

    Just include it on your page after jQuery.

    If you have multiple navbars on your pages (not very likely), set them specific ids and replace the classes .navbar-nav and .navbar-toggler in the code above with the proper ids.

    #8340
    kman201
    Participant

    Hmm, I am trying this, but not having any luck. I am using the code at for the .sm-blue theme at: https://www.smartmenus.org/about/themes/

    I have not changed the code. When using the mobile version (vertical menu) I am wanting it to collapse when I click a link.

    I notice your code says .navbar-nav instead of .main-nav as shown in the code. So, I changed that to fit. Also, I do not have any links that have a className of sm-collapsible. Am I supposed to add this className to each of the menu items that I want to collapse? If so, do I add it to the

  • or the tag?

    In either case, I have not been able to get it to work. Any suggestions?

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?