Peppe
Peppe

Reputation: 314

Search by text and retrieve the id

Is there a way to retrieve the id of a node while performing a search by text??

This is the example: http://jsfiddle.net/53cvtbv9/529/ As you can see, I've used 2 methods to retrieve the id of a node after the search:

console.log($('#jstree').jstree(true).search("Natural & Organic", false, true, '1.0'));

console.log($('#jstree').jstree('search', "Natural & Organic"));

In the first case I get an "undefined" output, whereas in the second case, I get a complex object (see the console).

How can I get the node id instead?? Furthermore, How can I avoid that the node found changes color?

Thanks

Upvotes: 0

Views: 286

Answers (1)

Nikolay Ermakov
Nikolay Ermakov

Reputation: 5061

You will get that info when the search.jstree event is fired, check data.res array in console.

Demo here - Fiddle:

.on('search.jstree', function(e, data) {
    console.dir(data.res);
});

To remove color override css rules for .jstree-default .jstree-search class, I made them blue in demo.

Upvotes: 1

Related Questions