I want to call loadBranch() on an open tree node. I am expecting it to replace the existing nodes, but it is appending nodes. Is there a way to clear the child nodes and reload just that branch?
I couldn’t find a simple solution to this either when I had to do it, so I made my own function.
function clearBranch(tree, branch) {
var child;
while (child = tree.data.getFirstChildId(branch) {
tree.data.remove(child);
}
}
You can call this function right before loadBranch
and there will be no duplicates. Below is a working example that uses this function.
Maybe there’s a cleaner way to do it, but it works.
If you want to reload a branch each time you click on it, your solution is correct.
However, if you need to load a branch once, you can use isBranch method to check whether an item has child items: http://webix.com/snippet/b07fb972