Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get full path of selected node in jstree?(root node to selected node)

Tags:

jquery

jstree

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

my jsTree is like:-

*A(root node)
  *b
  *C
    *D

and i want to get the full path of selected node on button click. if user select the *D folder then path should be "A/C/d",if user select C then path should be "A/C". any help suggestions will be appreciated

like image 500
R K Sharma Avatar asked Aug 20 '14 13:08

R K Sharma


2 Answers

I have used this:

.on('changed.jstree', function (e, data) {
  var path = data.instance.get_path(data.node,'/');
  console.log('Selected: ' + path); 
})
like image 200
ggrandes Avatar answered Oct 10 '22 00:10

ggrandes


you can found it simply by

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

here drives_tree is id of the jstree in my case

like image 32
Ash Avatar answered Oct 09 '22 23:10

Ash