I am using the jsTree jQuery plug-in with its "Checkbox" plug-in and using an async http request to lazy-load each level of the tree. All works great, except that I cannot get the tree to pre-select certain nodes after the first level. I am using the "selected" attribute to provide an array of ID's to preselect. ID's in the top level of the tree are correctly pre-selected. However, ID's in lower levels of the tree are not selected when the level loads. Am I missing something?
Here is the constructor code:
var myArrayOfIDs = new Array();
myArrayOfIDs[0] = '123'; //etc...
$(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() } }
}
}
)