• I have a client that I’ve built several two page sites for using underscores.me. On both, the main menu uses anchor links instead of page links, the menu’s both work fine except neither of them would close on clicking a link in mobile view. The first one I was able to fix with a jquery function of:

    $(".menu-toggle, #primary-menu li a").click(function() {
       $("#site-navigation").toggleClass("toggled"); 
    });

    I added this to the bottom of navigation.js and it worked fine to close the mobile menu after clicking the anchor link.

    The second site which is the URL I listed is built the same way, only real difference I can think of besides basic styling is that this site uses the Facebook video embed javascript just below the opening body tag per FB’s instructions. Same issue as before, everything worked but the mobile menu would not close after clicking one of the anchor links.

    I’ve tried the same solution as before to no luck, I also changed the jquery function to define $ as a function like this:

    (function($) {
        $( "#primary-menu li a" ).click(function() {
            $( "#site-navigation" ).removeClass( ".toggled" );
        });
    });

    I want to add, I did not have to do this with the other site. I’ve also tried making the function’s action to either toggleClass or simply removeClass, but neither have worked. The reason I defined jQuery on this second one is because I was getting the console error telling me that $ was not defined as a function. Once again, this did not impact the first one that is working.

    I’ve tried removing the facebook script as well, but have not had luck with it. I’ve tried linking this new jquery in it’s own main.js, did not work; then at the end of navigation.js like the first example, but this did not work; I also tried putting it in script tags just before the closing body tag in footer.php and it still did not work.

    Can anyone help shed some light on this?

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Mobile menu will not close on click’ is closed to new replies.