在我的服务器中,我以jsTree的格式返回JSON对象:
{"id":"value", "text":"value", "parent":"value"}
Run Code Online (Sandbox Code Playgroud)
我通过Ajax调用获得了它。Console.log向我显示了详细信息,但是jsTree给了我错误:
未捕获的TypeError:无法读取未定义的属性“子级”
视图:
$.ajax({
url: "/category",
dataType: 'json',
type: 'GET',
success: function (res) {
$.each(res, function (i, obj) {
products.push([obj.id, obj.parent, obj.text]);
$('#jstree_demo_div').jstree({
'core': {
'data': [{ "id": obj.id, "parent": obj.parent != 0 ? obj.parent : "#", "text": obj.text }]
}
});
console.log(obj.parent != 0 ? obj.parent : "#");
});
}
});
Run Code Online (Sandbox Code Playgroud) 我试着用这个:
$("#jstree_demo_div").jstree("destroy").empty();
Run Code Online (Sandbox Code Playgroud)
它会删除已检查的节点并重新加载树,但不会应用新的更改.任何建议将不胜感激.
在全球范围内,我需要取消选中我的树 checkBox