相关疑难解决方法(0)

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

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

来源:['type','typeahead','ahead']

查询:'类型'

返回:'type'和'typeahead'

-

查询:'提前'

回报:'前进'

我想让它返回'前进'和'打字'

我的代码:

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,
});
Run Code Online (Sandbox Code Playgroud)

已经有一个问题,但我不明白答案.

javascript twitter typeahead typeahead.js

18
推荐指数
1
解决办法
5785
查看次数

标签 统计

javascript ×1

twitter ×1

typeahead ×1

typeahead.js ×1