OdinaSpb / jstree

Automatically exported from code.google.com/p/jstree
0 stars 0 forks source link

Feature request: Enable exact multi word search for node titles #1013

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I use the jstree search plugin to search for multiple IDs in the title fields 
of my HTML tree and it has proven very helpful. Thank you!

I took the original jstree code and changed it as suggested 
(https://github.com/vakata/jstree/issues/10) to enable multi word searching in 
the title fields of the tree and it works fine.

Now, I would like to search for exact matches instead of using the 
"jstree_title_contains" search method (e.g. search word "ID:4" only matches 
with title "ID:4" and not with title "ID:400").

Maybe you could consider adding such a search method in the future?

Greetings,
Clara

Original issue reported on code.google.com by clara.se...@gmail.com on 29 Aug 2013 at 2:06

GoogleCodeExporter commented 9 years ago
I found a solution for my request and wrote my own search method for exact 
multi word searching in the title fields:

$.expr[':'].jstree_exact_title_multi = function(a,i,m){

    var word, words = [];
    var searchFor = m[3].toLowerCase().replace(/^\s+/g,'').replace(/\s+$/g,'');
    if(searchFor.indexOf(' ') >= 0) {
        words = searchFor.split(' ');
    }
    else {
        words = [searchFor];
    }
    for (var i=0; i < words.length; i++) {
        word = words[i];
        if((a.getAttribute("title") || "").toLowerCase() == word ) {
            return true;
        }
    }
    return false;

};

Original comment by clara.se...@gmail.com on 3 Sep 2013 at 9:30