user5147795
user5147795

Reputation:

how to get Tree meta data in fancytree jquery

$("#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

Answers (1)

maria
maria

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

Related Questions