• Resolved eska66

    (@eska66)


    Hello everyone!

    I’ve got a problem I believed had a solution on other thread, but just to some point and not entirely.

    The things is that my menu closes after I select a submenu of level 3.

    My menu structure:
    Parent menu
    Submenu 1
    Submenu 2
    Submenu 3

    After adding JS code given by @wptuki in his thread, When I select submenu 1 or 2, the menu stays open after loading selected page. The parent menu closes when I click one of the submenu 3 pages. To expand it fully again, I need just to click on the parent menu arrow again – then all submenus, including 3, show as expanded already. I’m sure this problem is connected with the parent menu code.
    I guess I’m not familiar enough with JS, could someone help me to solve this problem?

    I believe this code, found in another topic (by @wptuki), just needs to be modified, but I have really no clue how to do it properly.

    Code:
    (function($) {
    $( document ).ready(function() {
    $( “li.current_page_item” ).each(function( index ) {
    $(this).parent(‘.sub-menu’).slideToggle(‘fast’);
    $(this).parent().parent(‘.sub-menu’).slideToggle(‘fast’);
    });

    $( “li.current-menu-parent” ).each(function( index ) {
    $(this).parent(‘.sub-menu’).slideToggle(‘fast’);
    });
    });
    })(jQuery);

    Regards and kisses! ??

    • This topic was modified 6 years, 5 months ago by eska66.
Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter eska66

    (@eska66)

    problem solved

    Hey, could you let us know how you solved it? I am having the exact same problem…

    Thread Starter eska66

    (@eska66)

    Sure thing, I haven’t posted it because I doubted anyone had the same problem since there were no topics that matched my question. ??

    (function($) {
    $( document ).ready(function() {
    $( “li.current_page_item” ).each(function( index ) {
    $(this).parent(‘.sub-menu’).slideToggle(‘fast’);
    $(this).parent().parent(‘.sub-menu’).slideToggle(‘fast’);
    });
    
    $( “li.current-menu-ancestor” ).each(function( index ) {
    $(this).parent(‘.sub-menu’).slideToggle(‘fast’);
    });
    });
    })(jQuery);

    Simply, just replace ‘parent’ with ‘ancestor’ so it stays like “li.current-menu-ancestor”. That worked for my menu.

    Regards

    • This reply was modified 6 years, 5 months ago by eska66.
    • This reply was modified 6 years, 5 months ago by eska66.

    Hi, In what file of the theme have you changed the code?

    Thanks!

    In what file did you put the code above?

    Thanks!

    @eska66 Did you sideload a JS file in the header?
    Or is it ok to stick it in script tags?

    I never know what’s the best way for small additions…

    Thread Starter eska66

    (@eska66)

    @apequeno I downloaded ‘Scripts n Styles’ plug-in and pasted this code in ‘Scripts
    (for the head element)’ section. Should work.

    @ibby I personally prefer to stick to script tags, honestly speaking. It’s easier to change them later, if you know how to operate on them.

    I believe the scripts are easier way for small additions, if you know how to operate on them.

    Regards

    • This reply was modified 5 years, 9 months ago by eska66.

    I’m not sure if the base code has changed but the script is not working as you described, for me at least. The submenu remains closed even when on one of its pages.
    Probably I should put some time aside to actually look at it.

    Thread Starter eska66

    (@eska66)

    @ibby I’m a complete rookie regarding website designing, I wish I could help. I just checked my website, because I haven’t visited it for a while, but the side menu still works good, no base code changed or anything.

    The problem might be with the amount of sub-menus you got in your menu, I guess. If I had just one sub-menu less than I needed, that code would not even be neccessary to be attached to scripts. Or on the other hand, if you have one sub-menu more than I did, then the code I’ve given would have to be expanded somehow analogically to how mine cod has been.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Side menu closing after selecting submenu’ is closed to new replies.