add auto select one node

This commit is contained in:
luqiong 2014-08-20 09:43:57 +08:00
parent 5178689bf4
commit 846648f424
1 changed files with 11 additions and 1 deletions

View File

@ -19,7 +19,7 @@ function jstreeCreateNode(containerId,data,name,id,pos){
childNode = ref.create_node(parentNode,{text:name,id:id,data:data,type:"default"},pos);
if(childNode) {
ref.open_node(parentNode);
ref.select_node(childNode);
jstreeSelectNode(containerId,childNode);
}
}
@ -34,6 +34,16 @@ function jstreeDeleteNode(containerId){
return ref.element.context.id;
}
/**
* @param containerId the id of jstree container
* @param node the id of to be selected node
*/
function jstreeSelectNode(containerId,node){
var ref = $("#"+containerId).jstree(true);
ref.deselect_all();
ref.select_node(node);
}
/**
* @param containerId the id of jstree container