【发布时间】:2014-01-31 18:42:59
【问题描述】:
我根本无法让 jsTree“类型”插件在任何容量下工作,并且在我可以检测到的任何地方都没有触发错误。
1.) 我参考了这个SO Question 来通过鼠标单击打开/关闭节点,但该函数永远不会被执行。
2.) 对于“类型”插件,jsTree Plugin Documentation 表示:
要设置节点的类型,您可以使用 set_type 或 提供类型属性 与节点的数据。
我怀疑这是设置问题,因为“类型”设置都不起作用,但“上下文菜单”插件确实起作用,所以看起来所有脚本都已到位,我为“类型”做错了
有没有其他人遇到过这个问题,或者有人知道我哪里出错了吗?
HTML
<div id="jstree"></div>
<script>
$(function () {
$('#jstree').jstree({
"types" : {
"types" : {
"series_type" : {
"icon" : {
"image" : "images/seriesnode.png"
}
},
"default" : {
"select_node" : function(e) {
console.info(e);
this.toggle_node(e);
return false;
}
}
}
},
"plugins" : [ "types", "ui" , "contextmenu" ],
"contextmenu": { "items": {} },
"core" : {
'data' : {
'url' : 'series_tree_data.php'
}
}
});
});
</script>
AJAX 调用返回的 JSON 数据:
[
{ "id":"series_123120",
"parent":"#",
"text":"1945 - The Year That Changed The World",
"type":"series_type",
"state":{"opened":true}
},
{ "id":"title_2003150",
"parent":"series_123120",
"text":"Beginning of the End",
},
{ "id":"segment_3006200",
"parent":"title_2003150",
"text":"Full Program",
},
{ "id":"file_552973",
"parent":"segment_3006200",
"text":"1945_part_1.flv",
"icon":false
}
]
【问题讨论】: