Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #1369616

    Hello,

    in mobile view, at the moment when a submenu is clicked, the one which was previously opened remains opened.
    Is it possible to change setting so that only one submenu is opened?

    It will be more neat and navigation will be easier

    Maybe with some code like this
    https://splunktool.com/open-and-close-submenus-on-click-jquery

    Thank you
    Mauro

    #1369623
    #1369629

    Fantastic! A complex request solved in 20 minutes!
    Thank you Guenni007

    #1369631

    Well, we already know each other through your footer area. ;)

    #1369632

    Hi,

    Thanks for your help @guenni007! :)

    Best regards,
    Yigit

    #1369633

    @guenni007 Yes I certainly remember, the footer looks great!

    #1374349

    Hello,
    the code suggested by @guenni007 works like a charm in one site, but it does not do anything in another
    ######################
    function only_one_submenu_open_on_burger(){
    ?>
    <script>
    window.addEventListener(“DOMContentLoaded”, function () {
    (function($) {
    $(‘body’).on( ‘click touch’, ‘.av-active-burger-items > a’, function () {
    $(this).parent(‘li’).siblings().removeClass(‘av-show-submenu’);
    $(this).parent(‘li’).siblings().find(‘ul’).slideUp( “fast”);
    });
    $(‘body’).on( ‘click touch’, ‘.av-active-burger-items .av-width-submenu > a’, function () {
    $(this).closest(‘.sub-menu’).siblings().find(‘li’).removeClass(‘av-show-submenu’);
    $(this).closest(‘.sub-menu’).siblings().find(‘ul’).slideUp( “fast”);
    });
    })(jQuery);
    });
    </script>
    <?php
    }
    add_action(‘wp_footer’, ‘only_one_submenu_open_on_burger’);
    ###################

    Please see in private content
    Thank you
    Mauro

    #1374826

    Hi,
    I see that in the first site that Guenni007’s code is working in your mobile menu has sub-menu items, for which the toggling occurs.
    But on your second site I don’t see any sub-menus, all menu items are top level so there is nothing to toggle.
    Try making the menu on the second site like the first site.

    Best regards,
    Mike

    #1377023

    Hello,
    I have made the same sub-structure (please see https://imgur.com/a/jbtUjMi)
    and also was missing the option: Menu Icon Submenu items > Display submenu items on click

    but still it is not working as expected: if I click on SHOP, then OUR FRAGRANCES, and then I go to SAMPLES & KITS I should see all SHOP close, but it remains open

    Thank you
    Mauro

    #1377110

    Hi,
    I’m not sure what the issue is in the mobile menu, can you post your page publicly so @Guenni007 can also see the page and perhaps spot what can be adjusted in his code?

    Best regards,
    Mike

    #1377141

    the script is placed in the footer – if you have checked on the other installation that jQuery should also be loaded in the footer ( see performance settings of enfold ) , you need to be sure that these snippets are loaded afterwards.
    You can do this by giving the function a priority.

    add_action('wp_footer', 'only_one_submenu_open_on_burger', 999);
    

    maybe that is the difference ?

    #1377233

    999 make the difference
    Once again, thank you very much Guenni007

    #1377263

    Hi,
    Glad Guenni007 could help, thank you Guenni007, if you have any further questions please create a new thread and we will gladly try to help you. Thank you for using Enfold.

    Best regards,
    Mike

Viewing 13 posts - 1 through 13 (of 13 total)
  • The topic ‘Open on click a submenu and close the one previously opened’ is closed to new replies.