0

我正在使用此页面的建议:http: //jqueryui.com/autocomplete/ 我有一个如下列表

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

我想搜索 (...) 中的第一个字符。示例:键入

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

s:->显示:BASIC(单)

to: -> show: Erlang (总语言) ,Fortran (总 tran)

我该怎么办?谢谢

4

1 回答 1

0

覆盖默认过滤器

$.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/

于 2013-09-05T06:08:01.730 回答