I have given this much thought, but unfortunately it is not that easy
- the problem is the special styling the last visible node in each
children collection should have.
It will make closing and opening really heavy to render correctly,
especially on large trees.
I guess a simple (and heavy) way to go would be to:
.bind("search.jstree", function (e, data) {
$(this).find("li").hide().removeClass("jstree-last");
data.rslt.nodes.parentsUntil(".jstree").andSelf().show()
.filter("ul").each(function () { $
(this).children("li:visible").eq(-1).addClass("jstree-last"); });
})
.bind("clear_search.jstree", function () {
$(this).find("li").css("display","");
$(this).jstree("clean_node", -1);
});
This seems to work fine, now all you need to do is call search on the
tree instance:
$("#tree-container").jstree("search", val);
You can bind to the search field onkeyup event ... also you might want
to timeout the search, to prevent heavy DOM operations while the user
is still rapidly typing.
I hope this helps!
Cheers,
Ivan