ztree树形菜单
引入:
<script src="js/jquery.ztree.all.js"></script>
$(function(){
var setting={
callback:{
onClick: onClick, //点击事件
//onCllapse:zTreeOnCollapse,
//onExpand:zTreeOnexpand,
//beforeEditName:beforeEditName,
//beforeRemove:beforeRemove
},
view:{
nameIsHTML:true,
showTitle:false,
dblClickExpand:trye,
selectedMulti:false,
//addHoverDom:addHoverDom,
selectedMulti:false
},
data:{
simpleData:{
enable:true
}
},
edit:{
//enable:true,
//editNameSelectAll:true,
//showRemoveBtn:showRemoveBtn,
//showRemoveBtn:showRemoveBtn
}
};
var curTree=$.fn.zTree.init($("绑定元素id"),setting,zNodes//json);
})
json格式:
var zNodes=[{
name:"",
id:"",
pId:""//pId为父级id,如该没有则为空
},{
name:"",
id:"",
pId:"",
}..........
]
//点击事件:
function aa(event,treeld,treeNode){
treeNode.id //可获取点击的这个的id
}