【发布时间】:2014-03-30 09:01:06
【问题描述】:
默认情况下,twitter typeahead.js 只返回匹配字符串开头的元素,例如:
来源:['type','typeahead','ahead']
查询:'类型'
返回:'type' 和 'typeahead'
--
查询:'提前'
返回:'领先'
我希望它返回 '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,
});
已经有一个问题,但我不明白答案。
【问题讨论】:
标签: javascript twitter typeahead.js typeahead