Reputation:
$("#tree").fancytree({
source: [
{title: "Node 1", key: "1"},
{title: "Folder 2", key: "2", folder: true, children: [
{title: "Node 2.1", key: "3", myOwnAttr: "abc"},
{title: "Node 2.2", key: "4"}
]}
],
...
};
Now how can i get this myOwnAttr
value when node is activate?
If possible then give me working example not written solution. :)
Upvotes: 0
Views: 2981
Reputation: 366
Select the active node from tree:
var node = $("#tree").fancytree("getActiveNode");
The data object will hold the metadata from your tree, to get your custom attribute values you call it like this:
console.log(node.data.myOwnAttr);
Reference: https://github.com/mar10/fancytree/wiki/TutorialLoadData#passing-data-with-the-source-option
Upvotes: 2