我这样做了一个查询......第一次,它运行了过滤器......酷,它有效...
但是现在有更多的条目,它似乎正在运行缓存。如何强制它停止使用缓存?
var countries = new Bloodhound({
datumTokenizer: function (d) { return Bloodhound.tokenizers.whitespace(d.name); },
queryTokenizer: Bloodhound.tokenizers.whitespace,
limit: 10,
prefetch: {
url: Url + '/Country/JsonList',
filter: function (list) {
return $.map(list, function (country) { return { name: country.Name }; });
}
}
});
countries.initialize();
$('.countries.typeahead').typeahead(null, {
displayKey: 'name',
source: countries.ttAdapter()
});
答案 0 :(得分:19)
我认为这比接受的答案更好:
pandas.DataFrame.Set.map
答案 1 :(得分:7)
将ttl
属性添加到过滤器...并将其设置为1而不是0.
var countries = new Bloodhound({
datumTokenizer: function (d) { return Bloodhound.tokenizers.whitespace(d.name); },
queryTokenizer: Bloodhound.tokenizers.whitespace,
limit: 10,
prefetch: {
ttl: 1,
url: Url + '/Country/JsonList',
filter: function (list) {
return $.map(list, function (country) { return { name: country.Name }; });
}
}
});
countries.initialize();
$('.countries.typeahead').typeahead(null, {
displayKey: 'name',
source: countries.ttAdapter()
});
https://github.com/twitter/typeahead.js/blob/master/doc/bloodhound.md