• JSonJavaScript


     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");
    });
    }

      

  • 相关阅读:
    office 所有后缀对应的 content-type
    Vue 拖拽组件 vuedraggable 和 vue-dragging
    vue实现word,pdf文件的导出功能
    vue浏览器全屏实现
    对于js中事件冒泡的理解分析
    一个服务端的登录拦截
    ES6兼容ie9, flex兼容ie9
    webpack报错
    vue项目的一个package.json
    vue项目的构建过程
  • 原文地址:https://www.cnblogs.com/wzq806341010/p/3034532.html
Copyright © 2020-2023  润新知