0
我有一個變量,我想將它傳遞給$('#tree').jstree()
。將JSON作爲變量傳遞給jsTree
嘗試:
$('#tree').jstree({
plugins: ["checkbox", "types"],
"types": {
"file": {
"icon": "jstree-file"
}
},
'core': {
'data': mdata.data
}
});
//------------------------------
$('#tree').jstree({
plugins: ["checkbox", "types"],
"types": {
"file": {
"icon": "jstree-file"
}
},
'core': {
'data': JSON.stringify(mdata.data)
}
});
//------------------------------
$('#tree').jstree(mdata.data)
我的JSON變量(mdata.data
)由JSON.parse()
已經被解析。我已通過jsonlint.com驗證了它的有效性。那就是:
[{
"soslist": [{
"code_intext": "utf-8",
"count_of_pages": 2,
"count_of_records": 7,
"curobj": "1",
"obj": "1",
"page": 1
}, {
"code_intext": "utf-8",
"count_of_pages": 2,
"count_of_records": 7,
"curobj": "1",
"obj": "1",
"page": 1
}],
"system": [{
"count_of_pages": 2,
"count_of_records": 7,
"curobj": "1",
"page": 1
}]
}]
mdata.data
控制檯:
它甚至有可能還是需要jsTree具體JSON結構和類似的東西id
和parent_id
?