我正在使用 Bootstrap Treeview(bootstrap-treeview.js v1.0.2);如何在单击根时激活对根节点的所有子节点的选择效果?
此代码段未按预期工作
$('#tree')
.on('nodeSelected', function (event, node) {
children=node['nodes'];
for (var i = 0; i < children.length; i++) {
children[i].states.expanded = true;
children[i].states.selected = true;
}
});
这仅适用于第一个孩子
$('#tree')
.on('nodeSelected', function (event, node) {
children=node['nodes'];
for (var i = 0; i < children.length; i++) {
nodeId=children[i]['nodeId'];
console.log(nodeId);
$('.node-tree[data-nodeid="'+nodeId+'"]').click();
}
});