How to get the full path to the selected node in jstree? (Root node to selected node)

I want to create a directory management system where the user can create, rename, delete directories and save files in directories. I use jquery jstree for this.

my jsTree is like:- *A(root node) *b *C *D 

and I want to get the full path to the selected node when the button is clicked. if the user selects the folder *D , then the path should be "A/C/d" , if the user selects C, then the path should be "A/C" . any helpful tips would be appreciated

+5
source share
2 answers

I used this:

 .on('changed.jstree', function (e, data) { var path = data.instance.get_path(data.node,'/'); console.log('Selected: ' + path); }) 
+12
source

you can find it just

$('#drives_tree').jstree().get_path($('#drives_tree').jstree("get_selected", true)[0], ' > ')

here drives_tree is id jstree in my case

+1
source

Source: https://habr.com/ru/post/1200757/


All Articles