Ebad ghafoory
Ebad ghafoory

Reputation: 1304

jQuery TextExt set autocomplete suggestions to filter based on 'contains' rather than 'starts with'

I have some data like this in my Json file:

"Microsoft word"
"adobe Photoshop"
"PHP programming"

When i enter PHP in my text input, TextExt suggest me PHP Programming. But when i enter Program in text input, don't suggest any tag.

So autocomplete in TextExt just find first characters of any words. How i can fix this ?

Upvotes: 2

Views: 629

Answers (1)

Fred
Fred

Reputation: 1322

Looks like there's an open issue with a work around: https://github.com/alexgorbatchev/jquery-textext/issues/168

You can override how the ItemManager filters its list of suggestions:

p.itemContains = function(item, needle)
{
    return this.itemToString(item).toLowerCase().indexOf(needle.toLowerCase()) > -1;
};

The issue suggests modifying their core js file but you could always provide your own ItemManager via the options or monkey patch ItemManager.

Upvotes: 2

Related Questions