首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >推特Typeahead.js如何返回字符串中所有匹配的元素

推特Typeahead.js如何返回字符串中所有匹配的元素
EN

Stack Overflow用户
提问于 2014-02-27 13:38:37
回答 1查看 6.1K关注 0票数 18

默认情况下,推特typeahead.js只返回字符串开头匹配的元素,例如:

来源:'type','typeahead','ahead‘

查询:'type‘

返回:'type‘和'typeahead’

--

查询:'ahead‘

返回:'ahead‘

我想让它返回'ahead‘和'typeahead’

我的代码:

代码语言:javascript
复制
var clients = new Bloodhound({
    datumTokenizer: function(d) { return Bloodhound.tokenizers.whitespace(d.value); },
    queryTokenizer: Bloodhound.tokenizers.whitespace,
    limit: 10,
    prefetch: {
        url: '/clients.json',
        filter: function(list) {
            return $.map(list, function(value) { return { name: value }; });
        }
    }
});

clients.initialize();

$('.client').typeahead(null, {
    displayKey: 'value',
    source: clients.ttAdapter(),
    minLength: 1,
});

已经有一个关于它的问题了,但我不明白答案。

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22059933

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档