SideBar no close - Mobile / Tablet

Hey guys, Alright? hope so! Guys, I would like to know how it is done for the sidebar to go back as soon as a menu item is clicked.. Currently when you open the sidebar and click on a menu item... the page is loaded but it stays open... having to click again on the burger menu to close... Can anybody help me? - Mobile - Tablet Thank you!
3 answers



What we have done in the past is added an HTML snippet with JavaScript code to cause the menu to collapse when clicked outside of that element. Note that if you use this method, the menu will close by clicking on anything outside of the menu, such as a popup that has been pulled in from the menu.  Here is some code from Stack Overflow that can help you out. 


  // check if the clicked element is a descendent of navigation 
  if ($('.navigation').length) { // replace .navigation with the class of the menu bar
    return; //do nothing if event target is within the navigation
  } else {
  // do something if the event target is outside the navigation
     $('.navigation').collapse() // replace .navigation with the class of the menu bar