#6043 closed enhancement (wontfix)
Add "match at beginning" to autocomplete
Reported by: | beermad | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | |
Component: | ui.autocomplete | Version: | 1.8.4 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
In a couple of projects that I've used the autocomplete widget, I've found that it's been particularly useful to get it to ONLY match against the start of the strings in the "source" array.
So, for example if the user types "ad", it matches "adnams", "adkin", "adur" but doesn't match "Madeley", "Head", etc.
At the moment I can do this by editing the autocomplete Javascript so that:
var matcher = new RegExp( $.ui.autocomplete.escapeRegex(term), "i" );
becomes
var matcher = new RegExp( '^'+$.ui.autocomplete.escapeRegex(term), "i" );
I think it would probably be useful to other users of this useful widget if this were made a standard option that could be applied when creating an autocomplete widget.
Note: See
TracTickets for help on using
tickets.
We don't want to build in multiple searching methods in the core of the plugin. You can accomplish this by passing a custom function as the source option. Alternatively, you can create an extension to adds this option.