下面发布的代码通过ajax请求加载我的树的根元素。
我的树非常大,所以我不能一次加载所有项目所以我需要通过请求孩子加载特定ID来加载元素。
如何通过单击节点按ajax加载元素?
$('#jstree_demo_div')。jstree({
plugins:[wholerow,checkbox],
'core':{
'data':{
'url':function(node){
return/+ site +/ places / api / tree / list /;
}
},
}
});
json样本的一部分
[
{
text:zachodniopomorskie,
州:关闭,
id:212353,
},
固定版本:
$('#jstree_demo_div')。jstree({
plugins:[wholerow,checkbox],
'core':{
'数据':{
'url':/+ site +/ places / api / tree / list /,
'data':function(node){
return {
'id':node.id
};
}
},
}
})
我的问题的解决方案是,如果我想通过ajax请求返回子项,我需要返回包含以下内容的json文件:
children:true
解决方案
$('#jstree_demo_div')。jstree({
plugins:[wholerow,复选框],
'核心':{
'数据':{
'url':/+ site +/ places / api / tree / list /,
'data':function(node){
return {
'id':node.id
};
}
},
}
})
我的问题的解决方案是,如果我想通过ajax请求返回子项,我需要返回包含以下内容的json文件:
孩子:真正的
Code posted below loads root elements for my tree by ajax request.My tree is very large so I can't load all items at once so I need to load elements by requesting children for specific ID's.
How do I load elements by ajax by clicking on node?
$('#jstree_demo_div').jstree({
"plugins" : ["wholerow", "checkbox"],
'core' : {
'data' : {
'url' : function(node) {
return "/" + site + "/places/api/tree/list/";
}
},
}
});
Part of json sample
[
{
"text":"zachodniopomorskie",
"state":"closed",
"id":212353,
},
Fixed version:
$('#jstree_demo_div').jstree({
"plugins" : ["wholerow", "checkbox"],
'core' : {
'data' : {
'url' : "/" + site + "/places/api/tree/list/",
'data' : function(node) {
return {
'id' : node.id
};
}
},
}
})
The solution to my problem is that if I want to return children by ajax request I need to return json file which contains:
"children:" true
解决方案 $('#jstree_demo_div').jstree({
"plugins" : ["wholerow", "checkbox"],
'core' : {
'data' : {
'url' : "/" + site + "/places/api/tree/list/",
'data' : function(node) {
return {
'id' : node.id
};
}
},
}
})
The solution to my problem is that if I want to return children by ajax request I need to return json file which contains:
"children:" true
这篇关于jsTree通过ajax加载孩子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!