我一直在试验 jQuery.jsTree 库,需要一些帮助。请有人告诉我如何json_data
从外部.json
文件中读取。
$("#treeDemo").jstree({
"plugins" : [ "themes", "json_data", "ui", "types" ],
//"json_data": {
// "ajax" : {
// "url" : "Series.json"
// }
//},
"json_data" : {
"data" : [{"data":"Series 1","children":[{"data":"Season 1","children":[{"data":"Episode 1.avi","attr":{"rel":"file"}},{"data":"Episode 2.avi","attr":{"rel":"file"}},{"data":"Episode 3.avi","attr":{"rel":"file"}}],"attr":{"rel":"folder"}},{"data":"Season 2","children":[{"data":"Episode 4.avi","attr":{"rel":"file"}},{"data":"Episode 5.avi","attr":{"rel":"file"}}],"attr":{"rel":"folder"}}],"attr":{"rel":"folder"}},{"data":"Series 2","children":[{"data":"Season 1","children":[{"data":"Episode 1.avi","attr":{"rel":"file"}},{"data":"Episode 2.avi","attr":{"rel":"file"}},{"data":"Episode 3.avi","attr":{"rel":"file"}},{"data":"Episode 4.avi","attr":{"rel":"file"}}],"attr":{"rel":"folder"}}],"attr":{"rel":"folder"}},{"data":"Series 3","children":[{"data":"Episode 1.avi","attr":{"rel":"file"}},{"data":"Episode 2.avi","attr":{"rel":"file"}}],"attr":{"rel":"folder"}},{"data":"Series 1","children":[{"data":"Episode 1.avi","attr":{"rel":"file"}}],"attr":{"rel":"folder"}},{"data":"Series 2","children":[{"data":"Episode 1.avi","attr":{"rel":"file"}},{"data":"Episode 2.avi","attr":{"rel":"file"}}],"attr":{"rel":"folder"}}]
},
"types" : {
"max_depth" : -2,
"max_children" : -2,
"valid_children" : ["drive"],
"types" : {
"folder" : {
"valid_children" : ["default", "folder"],
"icon" : {
"image" : "images/folder.png"
}
},
"file" : {
"valid_children" : "none",
"icon" : {
"image" : "images/file.png"
}
}
}
},
"themes" : {
"theme" : "default",
"url" : "themes/default/style.css",
"dots" : true,
"icons" : true
},
"search" : {
"case_insensitive" : true,
"ajax" : {
"url" : "/static/v.1.0pre/_docs/_search_result.json"
}
}
})
所以上面的代码就像 jsTree 一样工作。注释json_data
插件假设从指定的“Series.json”文件中读取完全相同的 JSON 数据,但是,当代码运行时,只显示加载 gif。
请帮忙。
在此先感谢,格兰特