mmenu关闭所有子菜单并返回顶级默认状态 [英] mmenu close all submenus and return to top level default state
问题描述
我正在使用mmenu JQuery插件( http://mmenu.frebsite.nl/)
I am using the mmenu JQuery plugin (http://mmenu.frebsite.nl/)
我能够浏览菜单,打开菜单,关闭菜单等.
I am able to navigate through the menu, open the menu, close the menu, etc.
但是,我要关闭菜单时要做的是重置菜单-以便每次打开并触发侧面菜单时,它总是从默认状态开始.
What I want to do, though, when the menu is closed, is to reset the menu - so that each time the side menu is opened and fired, it will always start from the default state.
我的菜单被设置为默认状态,具有canvas行为和滑动子菜单.
My menu is set up as the default state, with offcanvas behaviour and sliding submenus.
关闭菜单后,我可以得到回调:
I am able to get a callback when the menu is closed:
var api = $("#menu").data( "mmenu" );
api.bind( "closed", function() {
alert("menu closed");
});
我发现了其他建议:
api.closeAllPanels();
或:
api.closeAllSubmenus();
但是这些都不起作用.
我还尝试了以下链接中的潜在方法:
I have also tried potential methods from the following links:
https://github.com/BeSite/jQuery.mmenu/issues/237
https://www.drupal.org/node/2352421
有人每次触发菜单后都设法使菜单返回到默认状态吗?
Has anyone managed to get the menu to return back to the default state each time the menu is fired?
推荐答案
将两者结合起来应该有效:
Combining the two should work:
var api = $("#menu").data( "mmenu" );
api.bind( "closed", function() {
api.closeAllPanels();
});
这篇关于mmenu关闭所有子菜单并返回顶级默认状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!