I currently have mmenu as my mobile menu. I need to be able to reset my menu to the first level upon close. As of now the default functionality leaves me where I left off while navigating deeper into the sub-level after closing the menu and re-opening it.
I'd greatly appreciate help with this matter.
Thank you!!
I was able to solve this by adding a javascript function to my menu, which enables it to navigate to the home level (#mm-1). It also allows you to open any panel by passing the relative link as a parameter. Please take a look at the following code:
HTML
Javascript
Hope this is helpful.
Try this on any menu click:
Trigger() is a JQuery function. When we click on back arrow on the top of submenu. Submenus get hidden. So when we use ".mm-subclose" the class of back arrow, Menu get reset to main level.
You could try to hack lib itself.
For instance:
a. find this code (ca. #374):
b. right after code above, you could insert something like this:
explanation:
Original mm code (one you are looking for) fires on panel being closed, regardless on how, or why it is being closed.
Code you just pasted, re-arranges classes used by mmenu engine to change mmenu states.
To make all transitions to happen more smoothly, visible section of panel (e.g. if you use iconbar extension) fades out, and after re-positioning of menu panels main iconbar is fading in.
Fred's answer works on a previous version of Mmenu but if you're using the latest version (latest at the time this was posted was 5.6.1), you can use the API methods like the following:
You could use the "closed" callback event to close all opened panels.
The trick to doing this -when you're using horizontal submenus (the default setting)- is to open the first panel (the "main" level menu).