N00ts / vue3-treeview

a simple treeview in vue js 3
MIT License
71 stars 61 forks source link

How to get the ID of the focused item? #31

Closed hirisov closed 1 year ago

hirisov commented 1 year ago

Hello,

from the https://codesandbox.io/s/events-7st2s?from-embed=&file=/src/App.vue:355-385 example we can see how to bind a custom handler to the nodeFocus event. But how can I get the ID of the element which triggered this event please? How do I know which node the user clicked on? :)

thanks, Gabor

hirisov commented 1 year ago

Never mind, got the solution:

<script>
function nodeFocus(event) {
    console.log(event.id)
}
</script>

<template>
                <treeview :config="treeConfig" :nodes="treeNodes" @nodeFocus="nodeFocus">
                </treeview>
</template>