Close MAIN menu after click/tap?
-
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!
-
Sorry, I should have included the URL where this appears:
http://breakoutbusinessbrands.com/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 9 years, 5 months ago by
megamenu.
Thanks for the help, Tom! That seems to have helped with mobile, but unfortunately, it seems to have broken desktop menu usage:
http://breakoutbusinessbrands.comTapping on mobile screens now closes the menu, but clicking in desktop browsers will no longer open it.
Note that this is with the “external script loading from the footer” implementation.
Hi WhitG,
My bad, please can you check the link again? I have updated the code.
Regards,
TomThat did it, thanks so much!
-
This reply was modified 9 years, 5 months ago by
The topic ‘Close MAIN menu after click/tap?’ is closed to new replies.