jQuery mmenu intermittently opening on page load

I’m trying to figure out why mmenu is sometimes displaying as open when my page loads and other times it doesn’t. Even though I’m using wordpress, I’m using the jQuery plugin (not the wordpress plugin). There’s nothing that stands out to me about the code I’m using and I’m not getting any errors. What am I missing here? I’m trying to follow the documentation on the site, but nothing is mentioned about this issue.

// html markup
<div class="col-md-1 pull-right" id="mobile-nav-link-container">
    <a id="mobile-nav-link" href="#mobile-nav">Menu</a>
</div>

// js
(function ($) {
    $(document).ready(function() {

        var menu = $("nav#mobile-nav");

        menu.mmenu({
            classes: 'mm-light',
            counters: true,
            offCanvas: {
                position: 'right'
            }
        });
        // Make sure that nav items with sub-menus have non-clickable parent links.
        var hasChildren = menu.find(".page_item_has_children");
        var childLink = hasChildren.find('a.mm-next');
        childLink.addClass('mm-fullsubopen');

    });
})(jQuery);

// php for wordpress
<nav id+"mobile-nav">
  <?php
    wp_nav_menu(array(
      'theme_location' => 'header-menu',
      'container' => false
    ));
  ?>
</nav>

Read more here: jQuery mmenu intermittently opening on page load

Leave a Reply

Your email address will not be published. Required fields are marked *