I am using the jsTree jQuery plugin with its "Checkbox" plugin and using an asynchronous HTTP request to lazily load each level of the tree. Everything works fine, except that I cannot get the tree to pre-select specific nodes after the first level. I use the "selected" attribute to provide an array of IDs for preselection. The identifier at the top level of the tree is correctly selected. However, the identifier at lower levels of the tree is not selected when loading the level. Did I miss something?
Here is the constructor code:
var myArrayOfIDs = new Array();
myArrayOfIDs[0] = '123';
$(sDivID).tree(
{
data : {
async : true,
opts : {url : sURL}
},
plugins:{
"checkbox" : {three_state : false}
},
selected : myArrayOfIDs,
ui:{
theme_name : "checkbox",
dots : false,
animation : 400
},
callback : {
beforedata : function(NODE, TREE_OBJ) { return { id : $(NODE).attr("id") || 0, rand : Math.random().toString() } }
}
}
)
source
share