本文共 848 字,大约阅读时间需要 2 分钟。
然后写个标签,用来存放你的树状菜单:
tzs = {};tzs.index = { //初始化页面 init: function () { tzs.index.doCreateTree(); }, //给标签绑定事件 event : function(){ }, doCreateTree : function(){ $.getJSON("/user/queryJsTree",function(rs){ $('#myJstree').jstree({ "core" : { "mutiple" : false, "check_callback" : true, "data" : rs.data } }); }); //树节点左键相应函数(监听) $('#myJstree').on("select_node.jstree",function (node,selected,event) { //当前点击的对象的id alert(selected.node.id); }) }};$(function(){ tzs.index.init();});
注意:返回数据的对象需要有id,parent,text属性,用来区分他们的父亲是谁,我的jstreeVO是这样定义的:
starry.每天进步一点点❤