• Resolved WhitG

    (@whitg)


    Hi guys,

    Awesome plugin, thanks for putting it out there! It’s working well for my new project, which is launching this morning, but I’m having trouble effecting a particular behavior and I can’t figure out where the source of the problem lies. The behavior in question is this one, but with the main menu, not the mobile menu (I’m using the former for all devices):
    https://www.maxmegamenu.com/documentation/close-mobile-menu-after-click/

    I tried modifying this to match the main menu’s classes, but it’s not working:

    jQuery(document).ready(function($) {
        $("a.mega-menu-link").on('click', function(e) {
            $(".mega-menu-open").removeClass("mega-menu-open");
    		jQuery('#mega-menu-top-navigation').data('maxmegamenu').hideAllPanels();
        });
    });

    One possible problem area is where this code is being placed. I’ve tried including it in the header between <script></script> tags, as well as loading the same thing in the footer and finally in an external ‘.js’ file. So it’s possible that the implementation is flawed. It’s also possible that there’s a conflict with the Divi theme that’s stopping the script from executing. And of course it’s possible that my modified script isn’t right.

    Any ideas? Thanks!

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter WhitG

    (@whitg)

    Sorry, I should have included the URL where this appears:
    https://breakoutbusinessbrands.com/

    Plugin Author megamenu

    (@megamenu)

    Hi WhitG,

    It will be a problem with the placement of the JavaScript I think – MMM will automatically unbind any previously bound events.

    I’ve just updated the link with some new code, please could you check again?

    Regards,
    Tom

    • This reply was modified 8 years ago by megamenu.
    Thread Starter WhitG

    (@whitg)

    Thanks for the help, Tom! That seems to have helped with mobile, but unfortunately, it seems to have broken desktop menu usage:
    https://breakoutbusinessbrands.com

    Tapping on mobile screens now closes the menu, but clicking in desktop browsers will no longer open it.

    Thread Starter WhitG

    (@whitg)

    Note that this is with the “external script loading from the footer” implementation.

    Plugin Author megamenu

    (@megamenu)

    Hi WhitG,

    My bad, please can you check the link again? I have updated the code.

    Regards,
    Tom

    Thread Starter WhitG

    (@whitg)

    That did it, thanks so much!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Close MAIN menu after click/tap?’ is closed to new replies.