pawelczak / EasyAutocomplete

JQuery autocomplete plugin
http://easyautocomplete.com
MIT License
729 stars 244 forks source link

Support match by a function #409

Closed vanduc1102 closed 5 years ago

vanduc1102 commented 5 years ago

Current

list: {
        match: {
            enabled: true
        }
    }

It cant match the case, i typed vin homes

ELK server returns

[
 'vinhomes abc'
  'nice homes'
]

I got no result.

Expected:

list: {
        match: {
            enabled: function (item, input) {
                                   // implement here
                                 return 'matched word';
                         }
        }
    }
vanduc1102 commented 5 years ago

My bad, the feature is working well

sample from my implementation.

match: {
                enabled: true,
                method(element, input) {
                    const words = input.split(' ');
                    const matches = words.filter(w => element.search(w) > -1);
                    return matches.length > 0;
                }
            }