Tagged: Mobile Menu
- This topic has 2 replies, 2 voices, and was last updated 9 years, 10 months ago by Sakin.
-
AuthorPosts
-
February 19, 2015 at 5:20 am #51965RonelMember
Hello Sakin
My website is http://novelnatter.com
My website will (eventually) have a large number of items in some of the sub-menus, so I would like to be able to open and close sub-menus in mobile view, otherwise the menu will become unwieldy.
In order to do this, I have replaced the script adventurous-custom.min.js with adventurous-custom-child.min.js. This is fine and the existing scripts work as before.
I tested my script in jsfiddle (see https://jsfiddle.net/hvy9wxy9/23/) and it works fine.
However the IDENTICAL script in the theme, causes a problem whereby one of the if statements is running twice. Specifically, the if statement in the following function:
jQuery(“li.menu-item-has-children > a”).click(function(event){
event.preventDefault();if(jQuery(this).parent().hasClass(“open”)){
jQuery(this).next(“ul”).slideUp(500);
jQuery(this).parent().removeClass(“open”);
} else {
jQuery(this).next(“ul”).slideDown(500);
jQuery(this).parent().addClass(“open”);
}
});You can see what I mean if you compare the mobile menu on my site with that on the fiddle. The fiddle submenus slide open and closed without issues. The website submenus slide open and immediately thereafter slide closed again, instead of staying open. I swear the code is identical.
Any insight you can provide as to what could be causing this would be much appreciated.
Thank you and regards,
RonelFebruary 19, 2015 at 6:05 am #51967RonelMemberI figured out what was causing it, so the problem is solved, but I don’t really understand it.
The function adventurous_mobile_menu is called twice, once for the header right menu and once for the secondary menu. If I remove the second call, my code works. This is fine for me since I only have the one menu but I’d still be interested in knowing how I could change my code so that it works with two calls. I assume it’s happening because the user clicks on a cloned nav, rather than a unique nav in the header?
February 19, 2015 at 11:40 am #51979SakinKeymaster@Ronel: Yes you are really advance. Yes there is 2 calls to duplicate Header Right Menu and Secondary Menus. So, if you want two then you can make another function to duplicate the menu for secondary menu and then call it once for each menu.
-
AuthorPosts
- The topic ‘Mobile menu accordian for sub-menu’ is closed to new replies.