默认情况下,推特typeahead.js只返回字符串开头匹配的元素,例如:
来源:'type','typeahead','ahead‘
查询:'type‘
返回:'type‘和'typeahead’
--
查询:'ahead‘
返回:'ahead‘
我想让它返回'ahead‘和'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,
});
已经有一个关于它的问题了,但我不明白答案。
https://stackoverflow.com/questions/22059933
复制相似问题