我在jstree配置中做错了但我找不到。 它阻止我删除节点,当我使用默认配置删除id = 106的节点时,它工作正常。所以至少我知道我的HTML是正确的。
这是工作默认代码
$('#jstree').jstree({ core : { check_callback : true } });
var t = $('#jstree').jstree(true);
t.select_node('106');
t.delete_node(['106']);
这是我的配置
$("#jstree").jstree({
"core": {
"animation": 0,
"check-callback": true,
"themes": {
"icons": true,
"stripes": true,
}
},
// plugins
"plugins": [
"contextmenu", "types"
],
"types": {
"root": {
"icon": "glyphicon glyphicon-tree-deciduous"
},
"folder": {
"icon": "glyphicon glyphicon-tags"
},
"tag": {
"icon": "glyphicon glyphicon-tag"
},
},
// modify the contextmenu content with customMenu() function
"contextmenu": {
"items": function($node) {
return {
"Create": {
"separator_before": false,
"separator_after": false,
"label": "Create Folder",
"action": function(obj) {
this.node_create();
}
},
"Rename": {
"separator_before": false,
"separator_after": false,
"label": "Rename",
"action": function(obj) {
this.node_rename();
}
},
"Remove": {
"separator_before": false,
"separator_after": false,
"label": "Delete",
"action": function(obj) {
var t = $('#jstree').jstree(true);
t.select_node('106');
t.delete_node(['106']);
}
}
};
}
}
});
我查了解其他答案,但他们没有帮助。 我发现问题出在哪里,看到我的答案。
答案 0 :(得分:0)
您的代码有一个错误,可能无法解决问题但可以提供帮助。 参见:
$("#jstree").jstree({
"core": {
"animation": 0,
"check-callback": true,
"themes": {
"icons": true,
"stripes": true,
}
},
// plugins
"plugins": [
contextmenu", "types"
],
"types": {
"root": {
"icon": "glyphicon glyphicon-tree-deciduous"
},
"folder": {
"icon": "glyphicon glyphicon-tags"
},
"tag": {
"icon": "glyphicon glyphicon-tag"
}, //This "," cannot display here, because is last of the group
},
...
希望有助于解决您的问题! :)
答案 1 :(得分:0)
我发现了错误
我不得不改变
"check-callback": true,
到
"check_callback": true,