简体   繁体   English

jQuery自动完成匹配

[英]jquery autocomplete matching

I'm using this JQuery Autocomplete plugin . 我正在使用这个JQuery Autocomplete插件 It seems that by default it matches from the start, so "foo" would match "fool", but not "bufoon". 似乎默认情况下它从一开始就匹配,因此“ foo”将匹配“ fool”,但不匹配“ bufoon”。

I want the matching to occur anywhere and case insensitively, such that "foo" would match 我希望匹配发生在任何地方且不区分大小写,以使“ foo”匹配

  • fool 傻子
  • bufoon bufoon
  • Foo Fighter Foo Fighter

The options don't appear to be documented anywhere, so I had a look though the source code to figure out if this is possible but couldn't find any obvious way to change the matching algorithm, but I find it hard to believe this isn't supported. 这些选项似乎没有任何地方的文档,因此我看了一下源代码以查明是否可行,但找不到任何明显的方法来更改匹配算法,但我很难相信这是可行的不支持。

There is an option, matchContains , that is false by default. 有一个选项matchContains ,默认情况下为false。 Set it to true. 将其设置为true。 Example

Here is a list of options . 这是选项列表 Be Sure to click the "options" tab 确定点击“选项”标签

I have done something similar. 我做了类似的事情。 That's how you can do it: 那是你可以做到的:

.autocomplete({
    source : function(request, response) {
        var term = request.term.toLowerCase();
        // generating the array which matches the search term.
        response(autocompleteArr);
    }
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM