我有以下jquery代码,它利用jstree插件构建树,搜索并选择树。当我用户选择一个节点时,它会打开一个新的浏览器选项卡。当我第一次加载第一页时,我需要根顶级根节点作为默认选择。我在ui下尝试了initial_select,但它没有用。有什么想法吗?
$(document).ready(function(){
$("#tree").jstree({
"xml_data" : {
"ajax" : {
"url" : "jstree.xml"
},
"xsl" : "nest"
},
"themes" : {
"theme" : "classic",
"dots" : true,
"icons" : true
},
"ui": {
"initially_select" : [ "root" ]
"save_selected" : false
},
"search" : {
"case_insensitive" : true,
"ajax" : {
"url" : "jstree.xml"
}
},
"plugins" : ["themes", "xml_data", "ui","types", "search", "cookies"]
}).bind("select_node.jstree", function (event, data) {
$("#tree").jstree("toggle_node", data.rslt.obj);
var isTeamNode = false;
var node_id = data.rslt.obj.attr("id");
if (node_id.indexOf("team") >= 0)
{
isTeamNode = true;
$.cookie("example", node_id, { path: '/', expires:7 });
window.open('new_tab.html', '_newtab');
}
});