Dónal
Dónal

Reputation: 187499

jquery autocomplete matching

I'm using this JQuery Autocomplete plugin. It seems that by default it matches from the start, so "foo" would match "fool", but not "bufoon".

I want the matching to occur anywhere and case insensitively, such that "foo" would match

The options don't appear to be documented anywhere, so I had a look though the source code to figure out if this is possible but couldn't find any obvious way to change the matching algorithm, but I find it hard to believe this isn't supported.

Upvotes: 0

Views: 1945

Answers (2)

styrr
styrr

Reputation: 829

I have done something similar. That's how you can do it:

.autocomplete({
    source : function(request, response) {
        var term = request.term.toLowerCase();
        // generating the array which matches the search term.
        response(autocompleteArr);
    }
});

Upvotes: 0

Joe
Joe

Reputation: 82584

There is an option, matchContains, that is false by default. Set it to true. Example

Here is a list of options. Be Sure to click the "options" tab

Upvotes: 4

Related Questions