Velvet Star Monitor

Standout celebrity highlights with iconic style.

general

jqTree getSelectNode Function

Writer Matthew Martinez

I'm new to jqTree. I am trying to use the function: getSelectedNode found here: jqTree functions I have my tree working and being displayed using my own data as well as the sample data within this function:

 $(function() { $('#tree1').tree({ data: data, dragAndDrop: true, autoOpen: 1 }); });

Using the jqTree function below, I only ever get "null" out on loading the page. Furthermore nothing changes when I select a node.

 var node = $('#tree1').tree('getSelectedNode'); console.log(node);

I have also tried the given sample:

 var node = $tree.tree('getSelectedNode'); console.log(node);

In this case I get $tree not defined

Essentially, what am I doing wrong? How does these type of jqTree functions work? Tks !

1 Answer

It appears that you have to wrap this function in a click event. But of course, the docs don't tell you that. I found the source here: jqTree I htis helps someone else.

$('#tree1').bind(
'tree.click',
function(event) { // The clicked node is 'event.node' var node = event.node; alert(node.name);
}

);

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.