$("#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"}
]}
],
...
};
现在,当节点激活时,如何获得此myOwnAttr
值?
如果可能,请给我一个工作示例而不是书面解决方:)
答案 0 :(得分:2)
从树中选择活动节点:
var node = $("#tree").fancytree("getActiveNode");
数据对象将保存树中的元数据,以获取您调用它的自定义属性值,如下所示:
console.log(node.data.myOwnAttr);
参考:https://github.com/mar10/fancytree/wiki/TutorialLoadData#passing-data-with-the-source-option