Tagged: 

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #51965
    Ronel
    Member

    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,
    Ronel

    #51967
    Ronel
    Member

    I 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?

    #51979
    Sakin
    Keymaster

    @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.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Mobile menu accordian for sub-menu’ is closed to new replies.