【发布时间】:2014-01-13 16:20:11
【问题描述】:
我正在使用jsTree 3.0.0,我需要通过以下方式之一修改上下文:
- 更改默认项目的标签语言,禁用一些默认项目并添加新项目。
- 重写所有项目并将创建、重命名和删除功能绑定到一些新项目。
我尝试了几种方法,但都没有奏效。例如,当我单击创建时,这将返回 Uncaught TypeError: Object [object global] has no method 'create'。
"contextmenu":{
"items": function($node) {
return {
createItem : {
"label" : "Create New Branch",
"action" : function(obj) { this.create(obj); alert(obj.text())},
"_class" : "class"
},
renameItem : {
"label" : "Rename Branch",
"action" : function(obj) { this.rename(obj);}
},
deleteItem : {
"label" : "Remove Branch",
"action" : function(obj) { this.remove(obj); }
}
};
}
},
如果我尝试像下一个示例一样添加一项,我会丢失默认菜单项:
items : {
"create_folder" : {
"separator_before" : false,
"separator_after" : false,
"label" : "Create Folder",
"action" : function (obj) { alert(1); /* this is the tree, obj is the node */ }
}
}
我哪里错了?
【问题讨论】:
标签: javascript jquery contextmenu jstree