var _curmenu = '{"menus": [{"menuid":"1","menuname":"系统管理","url":"../Html/List.htm","icon":"img","menus":[{"menuid":"001","menuname":"栏目管理","url":"http://localhost:10756/Navigation/NavigationList#","icon":"img","menus":[{"menuid":"002","menuname":"用户管理1","url":"../Html/List.htm","icon":"img","menus":[]}]},{"menuid":"002","menuname":"用户管理","url":"../Html/List.htm","icon":"img","menus":[]},{"menuid":"003","menuname":"权限管理","url":"www.baidu.com","icon":"img","menus":[]}]}]}'; function strToJson(str) { var json = eval('(' + str + ')'); return json; } var _menus = strToJson(_curmenu); //初始化左侧 function InitLeftMenu() { var selectedPanelname = ''; $.each(_menus.menus, function (i, n) { var menulist = ''; menulist += '<ul class="navlist">'; $.each(n.menus, function (j, o) { menulist += '<li><div ><a ref="' + o.menuid + '" href="#" rel="' + o.url + '" ><span class="icon ' + o.icon + '" > </span><span class="nav">' + o.menuname + '</span></a></div> '; if (o.menus && o.menus.length > 0) { menulist += '<ul class="third_ul">'; $.each(o.menus, function (k, p) { menulist += '<li><div><a ref="' + p.menuid + '" href="#" rel="' + p.url + '" ><span class="icon ' + p.icon + '" > </span><span class="nav">' + p.menuname + '</span></a></div> </li>' }); menulist += '</ul>'; } menulist += '</li>'; }) menulist += '</ul>'; $('#nav').accordion('add', { title: n.menuname, content: menulist, border: false, iconCls: 'icon ' + n.icon }); if (i == 0) selectedPanelname = n.menuname; }); $('#nav').accordion('select', selectedPanelname); $('.navlist li a').click(function () { var tabTitle = $(this).children('.nav').text(); var url = $(this).attr("rel"); var menuid = $(this).attr("ref"); var icon = $(this).find('.icon').attr('class'); var third = find(menuid); if (third && third.menus && third.menus.length > 0) { $('.third_ul').slideUp(); var ul = $(this).parent().next(); if (ul.is(":hidden")) ul.slideDown(); else ul.slideUp(); } else { addTab(tabTitle, url, icon); $('.navlist li div').removeClass("selected"); $(this).parent().addClass("selected"); } }).hover(function () { $(this).parent().addClass("hover"); }, function () { $(this).parent().removeClass("hover"); }); }