【问题标题】:jQuery TextExt set autocomplete suggestions to filter based on 'contains' rather than 'starts with'jQuery TextExt 设置自动完成建议以基于“包含”而不是“开始于”进行过滤
【发布时间】:2015-06-23 15:29:46
【问题描述】:

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

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

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

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

【问题讨论】:

    标签: jquery ajax json autocomplete jquery-textext


    【解决方案1】:

    看起来有一个未解决的问题需要解决: 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

    【讨论】:

      猜你喜欢
      • 2015-01-14
      • 1970-01-01
      • 2020-03-15
      • 1970-01-01
      • 2021-07-22
      • 2023-03-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多