VIPC
VIPC

Reputation: 39

Get root element of fancytree

I have something like this :

-Root 1
--Folder 1
--Folder 2
---Element 1
-Root 2
--Folder 3
---Folder 4
----Element 2

I have a 'select' listener for elements and I need to choose the name or key of Root 1 or Root 2 when I choose Element 1 or Element 2 accordingly.

is $("#tree").fancytree("getRootNode") the right way and what exactly should I use to retrieve this information?

Upvotes: 2

Views: 2977

Answers (1)

mar10
mar10

Reputation: 14794

You can access the node and its parent in the event handler using node.getParentList():

select: function(event, data) {
    var parentNode = data.node.getParent(),
        topNode = data.node.getParentList()[0];
}

Upvotes: 1

Related Questions