【发布时间】:2017-06-16 12:18:19
【问题描述】:
我正在创建一个按钮以在选择节点后删除它们。我想让它只能删除子节点。为了做到这一点,我需要检查节点是否是父节点。
所以代码看起来像
$(".delete-node").click(function() {
// gets the selected nodes
$('#jstree1').jstree(true).get_selected();
if (data.instance.is_leaf) {
//My problem is HERE. Only delete if all nodes are children/not parent
//here I delete the nodes selected
$('#jstree1').jstree(true)
.delete_node($('#jstree1')
.jstree(true)
.get_selected());
}
});
我知道这很简单,但我似乎无法让它发挥作用。我对 jQuery 和 JavaScript 有点陌生,所以我错过了什么?
【问题讨论】:
标签: javascript jquery treeview jstree