【发布时间】:2014-02-27 09:25:35
【问题描述】:
我有一个 Typeahead 实例正在运行,从远程 URL 拉入 JSON,除了 UI 实例似乎忽略了我的几个选项,即“minLength”和“强调'。我使用的代码如下:
var airportsList = new Bloodhound({
name: 'airports',
limit: 20,
remote: {url: "http://full-url-here/search/%QUERY",
ajax: {type:'post',dataType:'jsonp',headers: {'cache-control': 'no-cache'}},
filter: function (parsedResponse) { return parsedResponse.locations; }
},
datumTokenizer: function(d) {
return Bloodhound.tokenizers.whitespace(d.name);
},
queryTokenizer: Bloodhound.tokenizers.whitespace
});
// initialize the bloodhound suggestion engine
airportsList.initialize();
// instantiate the typeahead UI
$('.typeaheadField').typeahead(null, {
displayKey: 'name',
minLength: 3,
highlight: true,
source: airportsList.ttAdapter()
});
查看我在 typeahead 实例中的参数,它肯定会获取 'displayKey' 和 'source' 的值,但由于某种原因似乎忽略了中间两个...?
【问题讨论】:
标签: typeahead.js twitter-typeahead