jstree自定义右键菜单
电脑版发表于:2020/7/16 18:25
自定义右键菜单:
重写contextmenu即可,把他放到contextmenu中
$("#你的树形id").jstree({
contextmenu:{
}
});
代码如下:
"contextmenu": { items: { add: { "label": "新增分组", "action": function (data) { var inst = jQuery.jstree.reference(data.reference); obj = inst.get_node(data.reference); layer.open({ type: 2, title: '新增[' + obj.text + ']的子组', shadeClose: true, area: ['380px', '300px'], content: '/admin/Group/add/id/' + obj.id //iframe的url }); } } , "edit": { "label": "修改分组", "action": function (data) { var inst = jQuery.jstree.reference(data.reference); var obj = inst.get_node(data.reference); var type = obj.id.substr(0, 4); if (type == 'root') { layer.msg('根节点无法修改', { 'time': 2000, 'icon': 2 }); return; } if (type == 'list') { layer.msg('考核对象分组请在系统设置-指标分组权限列表中修改', { 'icon': 2 }); return; } layer.open({ type: 2, title: '修改[' + obj.text + ']的子组', shadeClose: true, shade: 0.8, area: ['380px', '300px'], content: '/admin/Group/edit/id/' + obj.id //iframe的url }); } }, "del": { "label": "删除分组", "action": function (data) { console.log(data); } } } }