简体   繁体   English

mmenu js API - 菜单未显示

[英]mmenu js API - menu not showing

I want to use the mmenu js API but I'm having some difficulties.我想使用 mmenu js API 但我遇到了一些困难。

I was able to put a basic example up and running and all was fine.我能够启动并运行一个基本示例,一切都很好。 Next, I tried to add a searchfield but the searchfield wasn't showing.接下来,我尝试添加搜索字段,但未显示搜索字段。 At that point I realized that the source js file I was using didn't have the searchfield add-on.那时我意识到我使用的源 js 文件没有 searchfield 插件。

After some googling, I found a link to the jquery.mmenu.all.js file that supposedly has all of the add-ons.经过一番谷歌搜索,我找到了 jquery.mmenu.all.js 文件的链接,该文件据称包含所有附加组件。 But then I hit another problem.但后来我遇到了另一个问题。 You can see the animation of the menu but, it show up blank because its css display property is set to "none".您可以看到菜单的 animation 但它显示为空白,因为它的 css 显示属性设置为“无”。

I'm using the following javascript to call the API.我正在使用下面的 javascript 来调用 API。

var myMenu = $("#menu");

// initialize mmenu
myMenu.mmenu({
               "navbars": [
                  {
                     "position": "top",
                     "content": [
                        "searchfield"
                     ]
                  }
               ],
               "searchfield": {
                  "panel": true
               }
            }, {
               "searchfield": {
                  "clear": true
               }
            });

// initialize mmenu API
var myMenuAPI = myMenu.data( "mmenu" );


// function to set to specific subMenu
function setMMenu(subMenu) {
  // set to subMenu
  var current = myMenu.find(subMenu);

  // myMenuAPI.setSelected(current.first());
  myMenuAPI.openPanel(current.closest(".mm-panel")); 
}

// function to open mmmenu to specific subMenu
function openMMenu() {
  myMenuAPI.open();
}

You can see my problem in this fiddle.你可以在这个小提琴中看到我的问题。

http://jsfiddle.net/6anbksxd/ http://jsfiddle.net/6anbksxd/

Can you guys help me out here?你们能帮我吗?

Thanks in advance提前致谢

Add this to your CSS please.请将此添加到您的CSS中。

mm-menu.mm-offcanvas.mm-hasnavbar-top-1.mm-opened {
  display: block;
}

Updated JSFiddle .更新了 JSFiddle

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM