jsTree가 JSON 페이지에서 데이터를로드하고 올바르게 표시됩니다. 기본적으로 루트 노드를 선택하려고하는데 작동하도록 설정할 수 없습니다. 여기 처음에는 노드를 선택하기 위해 jQuery 플러그인 jsTree를 가져올 수 없습니다.
내 jQuery를하다 :$(function() {
$("#demo1").jstree({
"plugins" : [ "themes","json_data","ui" ],
"json_data" : {
"ajax" : {
"url" : "categorytreejson.asp"
},
"ui" : {
"initially_select" : [ "root" ]
},
}
});
});
여기
JSONLint를 사용하여 유효성을 검사 categorytreejson.asp에서 내 JSON입니다 :
{
"data": "root",
"attr": {
"id": "root"
},
"children": [
{
"data": "Photography",
"attr": {
"id": "Photography"
},
"children": [
{
"data": "Lenses",
"attr": {
"id": "Lenses"
},
"children": [
{
"data": "Telephoto",
"attr": {
"id": "Telephoto"
}
},
{
"data": "Macro",
"attr": {
"id": "Macro"
}
},
{
"data": "Other",
"attr": {
"id": "Other"
}
}
]
}
]
}
]
}
여기
는 결과 HTML입니다 :
가<li class="jstree-last jstree-open" id="root"><ins class="jstree-icon"> </ins><a class="" href="#"><ins class="jstree-icon"> </ins>root</a>
<ul style="">
<li class="jstree-closed" id="Photography"><ins class="jstree-icon"> </ins><a class="" href="#"><ins class="jstree-icon"> </ins>Photography</a>
<ul>
<li class="jstree-last jstree-closed" id="Lenses"><ins class="jstree-icon"> </ins><a href="#"><ins class="jstree-icon"> </ins>Lenses</a>
<ul>
<li class="jstree-leaf" id="Telephoto"><ins class="jstree-icon"> </ins><a href="#"><ins class="jstree-icon"> </ins>Telephoto</a>
</li>
<li class="jstree-leaf" id="Macro"><ins class="jstree-icon"> </ins><a href="#"><ins class="jstree-icon"> </ins>Macro</a>
</li>
<li class="jstree-last jstree-leaf" id="Other"><ins class="jstree-icon"> </ins><a href="#"><ins class="jstree-icon"> </ins>Other</a>
</li>
</ul>
</li>
</ul>
</li>
</li>
</ul>
</li>
</ul>
</li>
그리고 불을 지르고 볼 결과 데이터 개체 : 결과가 비어하지만 난 이유를 모르겠어요 때문에
args: []
inst: Object { data={...}, get_settings=function(), _get_settings=function(), more...}
rlbk: false
rslt: undefined
나는 문제의 대부분을 믿고있어 무엇입니까?
네 말이 맞아 use-, 항상 첫 번째 노드를 선택합니다. 나는 눈이 또 다른 것을 기쁘게 생각합니다. 대단히 감사합니다. 그래도 내가 왜 rslt 개체가 없는지 알 수 없습니다. – Chris