jQuery TextExt 将自动完成建议设置为基于 'contains' 而不是 'starts with' 进行过滤

jQuery TextExt set autocomplete suggestions to filter based on 'contains' rather than 'starts with'

我的 Json 文件中有一些这样的数据:

"Microsoft word"
"adobe Photoshop"
"PHP programming"

当我在文本输入中输入 PHP 时,TextExt 提示我 PHP Programming。 但是当我在文本输入中输入 Program 时,不建议任何标签。

所以 autocomplete 在 TextExt 中只查找任何单词的第一个字符。 我该如何解决这个问题?

似乎有一个未解决的问题需要解决: https://github.com/alexgorbatchev/jquery-textext/issues/168

您可以覆盖 ItemManager 过滤其建议列表的方式:

p.itemContains = function(item, needle)
{
    return this.itemToString(item).toLowerCase().indexOf(needle.toLowerCase()) > -1;
};

问题建议修改他们的核心 js 文件,但您始终可以通过选项或猴子补丁 ItemManager.

提供自己的 ItemManager