문제

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

도움이 되었습니까?

해결책

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/

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top