Skip to main content

Search and Top Navigation

#6043 closed enhancement (wontfix)

Opened September 11, 2010 05:20PM UTC

Closed September 12, 2010 03:45PM UTC

Last modified October 11, 2012 09:15PM UTC

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.

Attachments (0)
Change History (2)

Changed September 12, 2010 03:45PM UTC by scottgonzalez comment:1

resolution: → wontfix
status: newclosed

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.

Changed October 11, 2012 09:15PM UTC by scottgonzalez comment:2

milestone: TBD

Milestone TBD deleted