且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

有效的json以动态创建jstree节点

更新时间:2023-11-29 14:51:10

{ 
    "data" : "node_title", 
    // omit `attr` if not needed; the `attr` object gets passed to the jQuery `attr` function
    "attr" : { "id" : "node_identificator", "some-other-attribute" : "attribute_value" }, 
    // `state` and `children` are only used for NON-leaf nodes
    "state" : "closed", // or "open", defaults to "closed"
    "children" : [ /* an array of child nodes objects */ ]
}

如果您正在使用ajax从服务器获取json,请确保您创建这样的json结构

if you are using ajax to get json from server make sure you create json structure like this

[
    { "data" : "A node", "children" : [ { "data" : "Only child", "state" : "closed" } ], "state" : "open" },
    "Ajax node"
]

您可以看到它以获取详细信息

you can see this for details

http://www.jstree.com/documentation/json_data