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

R K Sharma picture R K Sharma · Aug 20, 2014 · Viewed 7.8k times · Source

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

Answer

ggrandes picture ggrandes · Mar 28, 2015

I have used this:

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