我正在尝试从MultiLevelPushMenu插件中提取当前元素的根路径。
https://github.com/adgsm/multi-level-push-menu
所有者已经提供了将根级路径提取到文档中的方法。/**
* Find path to root of selected menu level object
* Provides chain collection of menu level objects (root menu level object to given menu level object), or false in case of error
*/
$('#menu').multilevelpushmenu('pathtoroot', $menuLevelObject);
我已经按照指南使用了相同的方法,但是我得到的是HTMLLiobject,无法深入到路径中。
我需要将此集合转换为字符串格式的路径,有什么帮助吗?
这是我的代码...
$(document).ready(function(){
// HTML markup implementation, overlap mode
$( '#menu' ).multilevelpushmenu({
containersToPush: [$( '#pushobj' )],
menuWidth: '25%',
menuHeight: '100%',
onItemClick: function() {
// First argument is original event object
var event = arguments[0],
// Second argument is menu level object containing clicked item (
element)
$menuLevelHolder = arguments[1],
// Third argument is clicked item (
element)
$item = arguments[2],
// Fourth argument is instance settings/options object
options = arguments[3];
// You can do some cool stuff here before
// redirecting to href location
// like logging the event or even
// adding some parameters to href, etc...
var path = $('#menu').multilevelpushmenu('pathtoroot', $item);
alert(path);
}
});
});