4
我正在使用jstree插件来构建我的树。我在我的网页中有一个搜索框,我需要用户能够搜索jstree节点。使用jquery javascript搜索jstree节点
<fieldset id="search">
<input type="text" name="search_field" id="search_field" value="" />
<button id="search_tree">Search</button>
</fieldset>
当搜索点击,jstree节点应该扩大,如果发现的节点应该加以强调。如果未找到并且用户的错误应显示为“未找到”。我的代码展开下面的所有节点。有没有简单的方法来搜索jstree中的所有节点?
<script type="text/javascript">
$(document).ready(function(){
$("#search_tree").click(function() {
var value=document.getElementById("search_field").value;
$("#tree").jstree("search",value);
});
$("#tree").jstree({
"xml_data" : {
"ajax" : {
"url" : "jstree.xml"
},
"xsl" : "nest"
},
"themes" : {
"theme" : "classic",
"dots" : true,
"icons" : true
},
"search" : {
"case_insensitive" : true,
"ajax" : {
"url" : "jstree.xml"
}
},
"plugins" : ["themes", "xml_data", "ui","types", "search"]
});
});
</script>
我得到这个错误:
实例[...]为空或不是一个对象。这是一个jstree错误。有任何想法吗?
你谷歌? http://www.jstree.com/documentation/search – Johan 2013-02-19 14:36:09
@Johan,是的,我看着这个插件。我修改了我的帖子。仍然出现错误。有任何想法吗? – user1471980 2013-02-19 15:53:01