1
如果我JStree初始化函數是在同一個文件作爲來電顯示一切正常,但如果我將函數調用html文件它不回報什麼。這裏是我想出了到現在的代碼:裹JStree在功能和傳遞變量,如果功能是不一樣的文檔呼叫者不工作
function cattree(treeID, treeAncestors, treeCurrent) {
alert(treeID + treeAncestors + treeCurrent);
$("#"+treeID).jstree({
"core" : {
"initially_load" : treeAncestors,
},
"ui" :{
"select_limit" : 1,
"initially_select" : [treeCurrent],
},
"json_data" : {
"progressive_render" : true,
"progressive_unload" : true,
"ajax" : {
"url" : "/taxonomy/catjson",
"dataType": "text json",
"data" : function (n) {
return { id : n.attr ? n.attr("id") : 0 };
}
}
},
"plugins" : [ "themes", "json_data", "ui" ],
});
}
當我移動它來記錄我認爲它不會等待與函數加載文件。
$(document).ready(function(){
cattree("demo", ['4e974c91f0282e7011000004', '4e974d92f0282ec41a00000a'], ['4e974da1f0282e2c0c000000']);
}
);
這將是定時/順序問題。你能提供jsfiddle樣本嗎? – Radek
我相信這是在外部js加載之前調用函數的問題。 – Marius