marcojetson / type-ahead.js

A lightweight and extensible type ahead library
BSD 3-Clause "New" or "Revised" License
21 stars 6 forks source link

Allow for full-text search #12

Closed therebelrobot closed 9 years ago

therebelrobot commented 9 years ago

So here it only matches if the string is at index 0 of the list, we should probably allow for fulltext search if the user wants, so for example, if they have a list of thousands of options for autocomplete and don't know the exact string to get there. Will take a look at that today.

marcojetson commented 9 years ago

you can easily override the match method for the instance:

var t = new Typeahead();
t.match = function () {
    return candidate.indexOf(this.query) > -1;
};

or in the prototype:

Typeahead.prototype.match = function () {
    return candidate.indexOf(this.query) > -1;
};

The match method is very simple and I'm overriding it in my projects to support accented words. This was my idea for this library, only a few options but very easy to override or extend... But it makes sense to provide options for common used features.

therebelrobot commented 9 years ago

So was this an option that would be common enough to include? I'm cool rewriting my app to use the match override like you suggested, I just need to know b/c #13 is dependent on this, and I need to know whether to merge or close it (housekeeping :P)