How to get the Selected node in a tree?

I have a simple tree of documents, I want to find out what node was selected, I don’t want to link to the page. just return the selected node so I can use it in further processing. How can I do this?

Please help!

{{template name=“documentTree_macros.vm”/}}

{{velocity}}
{{html}}
#documentTree({})
{{/html}}
{{/velocity}}

…Do further processing…

The document tree is based on https://www.jstree.com . So all you need to do is to get a reference to the tree instance in JavaScript

jQuery.jstree.reference('.xtree')

(with a more specific selector because there may be multiple tree instances on the page) and then use the API documented at jsTree .

Thank You for your quick response!

Can this be done in velocity? or Am I going to have to write some JavaScript for this.

You need JavaScript. The tree is a widget written in JavaScript.