layui实现checkbox的目录树tree

来源:互联网 发布:ysl高仿包包淘宝 编辑:程序博客网 时间:2024/06/05 11:42

layui.use([ 'tree' ], function() {$ = layui.jquery;form = layui.form;//获取节点数据getTreeData();});function getTreeData(){$.ajax({url : path+"/RoleController/getResourceTree.do",type : "post",dataType : "json",data :{"roleId":roleId,"id":null,"t":Math.random()} ,error : function() {},success : function(data) {treeData = JSON.stringify(data);initMenuTree();}});}// 加载列表function initMenuTree() {//json数姐转换成对象treeData = eval( "(" + treeData + ")" );//console.log(treeData);// 执行渲染treeIns = layui.tree({elem: '#demo', //指定元素,生成的树放到哪个元素上check: 'checkbox', //勾选风格skin: 'as', //设定皮肤drag: true,//点击每一项时是否生成提示信息checkboxName: 'aa[]',//复选框的name属性值checkboxStyle: "",//设置复选框的样式,必须为字符串,css样式怎么写就怎么写click: function(item) { //点击节点回调 //alert(item);},change: function (item){//当当前input发生变化后所执行的回调//console.log(item);resourceIds=item;},data: {//为元素添加额外数据,即在元素上添加data-xxx="yyy",可选            hasChild: true        },nodes:treeData});return treeIns;}



原创粉丝点击