Question

I am using suggestion of this page: http://jqueryui.com/autocomplete/ I have a list like below

 var availableTags = [
  "ActionScript (bang ping)",
  "AppleScript (htore) ",
  "Asp (biga) ",
  "BASIC (single)",
  "Erlang (total lang) ",
  "Fortran (total tran)",
 ];

I want to search the first characters inside (...) . Example: typing

b: ->show: ActionScript (bang ping), Asp (biga)

s: ->show: BASIC (single)

to: -> show: Erlang (total lang) ,Fortran (total tran)

How i can do ? thanks

Was it helpful?

Solution

Overrides the default filter

$.ui.autocomplete.filter = function (array, term) {
    var matcher = new RegExp("\\(" + $.ui.autocomplete.escapeRegex(term), "i");
    return $.grep(array, function (value) {
        return matcher.test(value.label || value.value || value);
    });
};

http://jsfiddle.net/nEx5R/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top