phphe/he-tree-vue

Adding a node to a specific position

devla opened this issue · 2 comments

devla commented

Hey bro,

Instead of adding an item to the end of the list, is it possible to add it to a specific position (path)?

I need to have an add button on each item (node), and when click to add a new node right after it.

Thank you,
Vladimir

phphe commented

You can use Array.splice. e.g.:

const newNode = {/*your new node*/}
parent.children.splice(clickIndex, 0, newNode)
devla commented

Yes, I thought so, but I drank too much last night and it was easier to ask. Thanks for your time!