jstree 1.0 如何去掉默认右键菜单中的 edit 子菜单
发布网友
发布时间:2022-04-26 12:43
我来回答
共1个回答
热心网友
时间:2022-04-24 14:54
1、右键菜单需要配置插件contextmenu
默认右键功能:"plugins" : [ "themes", "html_data", "contextmenu" ]
无右键功能:"plugins" : [ "themes", "html_data" ]
这种情况会弹出为网页的右键菜单
2、去掉右键菜单,只要将相应的默认菜单项设为null
Javascript代码
$(function () {
$("#demo1").jstree({
"plugins" : [ "themes", "html_data", "contextmenu" ],
"contextmenu": {
"items": {
"create": null,
"rename": null,
"remove": null,
"*": null
}
}
});
});
3、自定义右键菜单
Javascript代码
$(function () {
$("#demo1").jstree({
"plugins" : [ "themes", "html_data", "contextmenu" ],
"contextmenu": {
"items": {
"create": null,
"rename": null,
"remove": null,
"*": null,
"弹出对话框": {
"label": "弹出对话框",
"action": function (obj) { alert(obj) }
},
"包含子级菜单": {
"label": "包含子级菜单",
"submenu": {
"cut" : {
"separator_before" : false,
"separator_after" : false,
"label" : "Cut",
"action" : function (obj) { alert("Cut") }
}
}
}
}
}
});
});