Search code examples
jqueryjstree

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


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


Solution

  • I have used this:

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