情不知从何起,一往而情深
排名
6
文章
199
粉丝
4
评论
3
ICP备案 :渝ICP备18016597号-1
网站信息:2018-2025TNBLOG.NET
技术交流:群号656732739
联系我们:contact@tnblog.net
公网安备:50010702506256
欢迎加群交流技术

jstree自定义右键菜单

6635人阅读 2020/7/16 18:25 总访问:1110467 评论:0 收藏:0 手机
分类: 前端

自定义右键菜单:

重写contextmenu即可,把他放到contextmenu中
$("#你的树形id").jstree({
    contextmenu:{
     }
});
代码如下:

  1. "contextmenu": {
  2.     items: {
  3.         add: {
  4.             "label""新增分组",
  5.             "action"function (data{
  6.                 var inst = jQuery.jstree.reference(data.reference);
  7.                 obj = inst.get_node(data.reference);
  8.                 layer.open({
  9.                     type2,
  10.                     title'新增[' + obj.text + ']的子组',
  11.                     shadeClosetrue,
  12.                     area: ['380px''300px'],
  13.                     content'/admin/Group/add/id/' + obj.id //iframe的url
  14.                 });
  15.             }
  16.         }
  17.         ,
  18.         "edit": {
  19.             "label""修改分组",
  20.             "action"function (data{
  21.                 var inst = jQuery.jstree.reference(data.reference);
  22.                 var obj = inst.get_node(data.reference);
  23.                 var type = obj.id.substr(04);
  24.                 if (type == 'root') {
  25.                     layer.msg('根节点无法修改', { 'time'2000'icon'2 });
  26.                     return;
  27.                 }
  28.                 if (type == 'list') {
  29.                     layer.msg('考核对象分组请在系统设置-指标分组权限列表中修改', { 'icon'2 });
  30.                     return;
  31.                 }
  32.                 layer.open({
  33.                     type2,
  34.                     title'修改[' + obj.text + ']的子组',
  35.                     shadeClosetrue,
  36.                     shade0.8,
  37.                     area: ['380px''300px'],
  38.                     content'/admin/Group/edit/id/' + obj.id //iframe的url
  39.                 });
  40.             }
  41.         },
  42.         "del": {
  43.             "label""删除分组",
  44.             "action"function (data{
  45.                 console.log(data);
  46.             }
  47.         }
  48.     }
  49. }



欢迎加群讨论技术,1群:677373950(满了,可以加,但通过不了),2群:656732739。有需要软件开发,或者学习软件技术的朋友可以和我联系~(Q:815170684)

评价

jstree添加点击事件

code show:$('#树形id').bind("activate_node.jstree",function(obj,e){ //获取当前节点 varcurrentNo...

jstree根据 ID 获取节点方法:

jstree根据 ID 获取节点方法: var node = $('#树形id').jstree("get_node", id);

jstree默认展开、收起

默认展开 // 所有节点加载完成后触发 $('#jstree1').on("ready.jstree", function(e, data) { // ...

jstree自定义二级右键菜单

代码如下:语法其实就是submenu addfile: { "label": "新建", submenu: { addHtm...

jstree事件中拿来绑定的原始数据

比如要拿到绑定的id其实里边有个original属性就是绑定上来的原始对象,这样就可以随便的拿到了,这个树形组件封装得还是很...

jstree获取当前选中节点与选中指定节点

获取jstree当前选中节点function getSelectNodeId() { var treeNode = $('#树形id').jstree(true).get_selected(t...

jstree的点击事件,改变事件等

直接贴代码: //加载完成后触发的事件 $('#tree_3').on("ready.jstree", function (e, data) ...

jstree 实现搜索功能

注意需要在初始化的时候plugins加上search "plugins" : [ "contextmenu", "dnd", &qu...