从页面到页面的多级推送菜单状态 [英] Multi-level push menu state from page to page
问题描述
我正在尝试使用我在此处找到的多级推送菜单:
I'm attempting to use a multi-level push menu I found here:
http://tympanus.net/codrops/2013/08/13/multi-level-push-menu/
这里也提供了来源。我已经调整了源代码,以我想要的方式工作。我在php包含了一些部分,这样当我从一个页面到另一个页面时,部分的重新加载很少。
The source is available there as well. I've adapted the source to work MOSTLY the way I want. I have pieces in php includes so that there is minimal reloading of portions when I go from page to page.
我无法坚持的一部分是实际的菜单在左侧。当我点击链接时,菜单消失/完全折叠。有没有人知道如何调整这个以便在页面导航时保存菜单状态?
The one part I can't get to stick is the actual menu on the left hand side. When I click on a link, the menu disappears/completely collapses. Does anyone know how I can adapt this so that the menu state is saved when navigating from page to page?
谢谢!
推荐答案
在他们的博客上建议在'_init'方法中将'this.open'更改为'true'。
It's suggested on their blog to change 'this.open' to 'true' within the '_init' method.
_init : function() {
...
this.open = true;
然而这对我不起作用!
在初始化时调用'_openMenu()'方法,在'this._init()'之后会扩展菜单,但可能会导致事件监听器出现问题,导致身体点击......
Invoking '_openMenu()' method at initialization time, right after 'this._init()' will expand menu but could potentially bring problems with event listener for body click...
function mlPushMenu( el, trigger, options ) {
this.el = el;
this.trigger = trigger;
this.options = extend( this.defaults, options );
// support 3d transforms
this.support = Modernizr.csstransforms3d;
if( this.support ) {
this._init();
this._openMenu(); // added
}
}
第二种可能性:
如果你想保存确切的菜单位置,也许你可以使用以下 jQuery多级推送菜单插件,然后在离开页面之前,确定当前菜单状态:
If you want to "save" exact menu position, perhaps you could use following jQuery multi-level push menu plug-in, and then before leaving the page, to determine current menu state:
var $ activeMenu = $('#menu')。multilevelpushmenu('activemenu');
此后你可以发布任何数据从它(例如'id')
Thereafter you can post whatever data from it (e.g. 'id')
var menuID = $ activeMenu.attr('id');
到下一页并使用'expand'方法再次查找和展开相同的菜单级别。
to the next page and use it in there to find and expand the same menu level again using 'expand' method.
$('#menu')。multilevelpushmenu('expand',$('#'+ menuID));
这篇关于从页面到页面的多级推送菜单状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!