You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
deleteNodeFunction: function (node) {
const nodePath = this.$refs["my-tree"].findNodePath(node.id);
const parentNodeId = nodePath.slice(-2, -1)[0];
if (parentNodeId === undefined) {
// 'root' node
const nodeIndex =
this.$refs["my-tree"].nodes.findIndex((x) => x.id !== node.id) - 1; **//this return -1 when list delete center. only work on end of nodes**
this.$refs["my-tree"].nodes.splice(nodeIndex, 1);**//when nodeIndex -1, this delete last of nodes always, not select one**
} else {
// child node
const parentNode = this.$refs["my-tree"].findNode(parentNodeId);
const nodeIndex =
parentNode.nodes.findIndex((x) => x.id !== node.id) - 1; **//this return -1 when list delete center. only work on end of nodes**
parentNode.nodes.splice(nodeIndex, 1); **//when nodeIndex -1, this delete last of nodes always, , not select one**
}
console.log("example: remove node", node.id);
},
------------------- my fix suggestion -----------------------
suggestion for sample, https://codesandbox.io/s/vuejs-tree-sandbox-v3x-lmbyx
------------------- my fix suggestion -----------------------
The text was updated successfully, but these errors were encountered: