requirejs整合ztree

简介: {block name='script'} require(['jquery.ztree'], function () { var zTreeObj; var setting = { view: { ...
{block name='script'}

<script>

    require(['jquery.ztree'], function () {
        var zTreeObj;
        var setting = {
            view: {
                showIcon: true
            },
            data: {
                simpleData: {
                    enable: true
                }
            },
            callback: {
                onClick: zTreeOnClick
            }
        };

        var zNodes =[
            { id:1, pId:0, name:"课程目录", open:true},
            { id:11, pId:1, name:"季度产品知识课程", open:true},
            { id:111, pId:11, name:"13Q4产品知识", },
            { id:112, pId:11, name:"14Q1产品知识", },
            { id:113, pId:11, name:"14Q2产品知识", },
            { id:114, pId:11, name:"14Q3产品知识", },
            { id:115, pId:11, name:"14Q4产品知识", },
            { id:12, pId:1, name:"项目宣讲类课程", open:true},
            { id:121, pId:12, name:"项目宣讲类课程1"},
            { id:122, pId:12, name:"项目宣讲类课程2"},
            { id:123, pId:12, name:"项目宣讲类课程3"},
            { id:13, pId:1, name:"移动商学院", open:true},
            { id:131, pId:13, name:"技能类"},
            { id:132, pId:13, name:"心态类"},
            { id:133, pId:13, name:"知识类"},
            { id:134, pId:13, name:"哈哈类"},
        ];

        zTreeObj = $.fn.zTree.init($("#zTree"), setting, zNodes);
        function zTreeOnClick(event, treeId, treeNode) {
            //这里定义点击书中节点时,相应的页面其他的操作,示例:
            // 每次点击节点后, 弹出该节点的 tId、name 的信息
            alert(treeNode.tId + ", " + treeNode.name);
        };
    });
</script>

{/block}

  

<div class="layui-row">

    <div class="layui-col-xs6 layui-col-md2">
        <style>
            .ztree {  margin: 0;  padding: 5px;  color: #333;  padding: 10px;  border: 1px solid #ddd;  overflow: auto;  }
            .ztree * {  padding: 0;  margin: 0;  font-size: 14px;  font-family: Verdana, Arial, Helvetica, AppleGothic, sans-serif;  }
            .ztree li a {  padding: 1px 3px 0 0;  margin: 0;  cursor: pointer;  height: 26px;  color: #333;  background-color: transparent;  text-decoration: none;  vertical-align: top;  display: inline-block;  }
            .ztree li a.curSelectedNode {  padding-top: 0px;  background-color: #FFE6B0;  color: black;  height: 26px;  border: 1px #FFB951 solid;  opacity: 0.8;  }
            .ztree li span.button.ico_docu {  margin-right: 2px;  background-position: -110px -32px;  vertical-align: text-bottom;  }
            .ztree li span {  line-height: 26px;  margin-right: 2px;  }
       </style>
        <ul id="zTree" class="ztree loading">
            <li></li>
        </ul>


    </div>
    <div class="layui-col-xs12 layui-col-md10" style="padding-left: 10px;">
    </div>
</div>

  

相关文章
|
JavaScript
原生js使用editor.js
原生项目中使用下一代块样式编辑器editor.js,自由,使用愉快。
原生js使用editor.js
|
5月前
|
JavaScript 前端开发 索引
学习了解JS的classlist
学习了解JS的classlist
44 0
|
JavaScript 前端开发 索引
深入学习js的classList
深入学习js的classList
152 0
拾色器插件colorpicker.js的应用
拾色器插件colorpicker.js的应用
48 1
|
存储 JavaScript 前端开发
JQuery jquerysessionjs插件使用介绍
JQuery jquerysessionjs插件使用介绍
102 0
|
存储 JSON JavaScript
JQuery Ztree 树插件配置与应用小结 2
JQuery Ztree 树插件配置与应用小结
201 0
|
JavaScript 前端开发 索引
|
Web App开发 JavaScript 前端开发