ezraroi / ngJsTree

Angular Directive for the famous JS Tree
http://ezraroi.github.io/ngJsTree/
MIT License
270 stars 101 forks source link

get selected node. #65

Closed hmendezm closed 8 years ago

hmendezm commented 8 years ago

Hi guys

First at all, thanks very much in put together this directive. I start using Today and really like it a lot. I have tried to get the node that is selected by the user in the reeview without any sucess. It is not clear for me how to use plugins in the directive. for example there is a plugins called changed that return the selected node but I do not know how to translate that following jstree code.

$(function () { $("#plugins") .on("changed.jstree", function (e, data) { console.log(data.changed.selected); // newly selected console.log(data.changed.deselected); // newly deselected }) .jstree({ "plugins" : [ "changed" ] }); });

So, the short question is how I can get teh selected node by the user so I can use it to show information related to the node.

Best Regards Henry

Simel commented 8 years ago

Hello Henry Something like this (from some example)?:

    var i, j;
    for (i = 0, j = data.selected.length; i < j; i++) {
        console.log(data.instance.get_node(data.selected[i]).id);
    }
ezraroi commented 8 years ago

Hi, you can look on the code of the sample page: https://github.com/ezraroi/ngJsTree/blob/gh-pages/treeCtrl.js

var selectedNode = vm.treeInstance.jstree(true).get_selected();
ermingzhu commented 4 years ago

i don't know the node struct,how can i use it

ermingzhu commented 4 years ago

the node struct json string is can't print out, api show the select node params node selected event, but how use it to get the node's id text ,parent node