dimanche 3 juillet 2016

jQuery conflict between cmap and mmenu

I have mmenu jQuery plugin and cMap plugin in wordpress which conflicts with each other only in the pages where both are required together. I keep getting an error that menu is not a function in only 1 page. which results that the left menu doesn't work in MOBILE VIEW

Console Error

Uncaught TypeError: $menuleft.mmenu is not a function

Javascript Code

jQuery(document).ready(function($) {
  /*
   * Let's fire off the gravatar function
   * You can remove this if you don't need it
  */
  loadGravatars();

  // $("nav#mobile-navigation-left").mmenu();
  // $(window).resize(function() { mmenuw(); });
  jQuery(document).ready(function( $ ){
    var $menuleft = jQuery("#mobile-navigation-left");

    if (jQuery('#menu-item-gd-location-switcher').length){

      $menuleft.on(
        "opened.mm",
        function()
        {       
          jQuery(".geodir_location_tab_container").detach().appendTo('#mm-mobile-navigation-left .gd-location-switcher-menu-item'); 
          jQuery('#mm-mobile-navigation-left .geodir_location_tab_container.mm-panel').remove(); 
        }
      );

      $menuleft.on(
        "closed.mm",
        function()
        {   
          jQuery("#mm-mobile-navigation-left .geodir_location_tab_container").detach().appendTo('#menu-item-gd-location-switcher .gd-location-switcher-menu-item');
        }
      );
    }

    $menuleft.mmenu({},{clone: 1});// clone it so we can do responsive

    var $menu = jQuery('#mobile-navigation-right');
    $menu.mmenu({
      position : 'right',   
      isMenu : false,
      panelClass : 'profile-sub-menu' // class of the div that holds the login menu
    });
  });
});

Here's the website that faces this error (please view in mobile mode or resize your browser): Live Version with ERROR

Example on same website of working page with no error: Working Live Version

Aucun commentaire:

Enregistrer un commentaire