我正在使用typeahead.js v0.10.1,我想知道是否有办法让搜索结果出现在另一个div而不是下拉列表中?
HTML:
<div class="col-sm-6 films">
<input class="typeahead form-control" type="text"/>
</div>
<div class="results">Have the results appear in here</div>
的javascript:
var films = new Bloodhound({
datumTokenizer: function (d) {
return Bloodhound.tokenizers.whitespace(d.value);
},
queryTokenizer: Bloodhound.tokenizers.whitespace,
limit: 10,
local: [{
"year": "1961",
"value": "West Side Story",
"tokens": [
"West",
"Side",
"Story"]
}, {
"year": "1962",
"value": "Lawrence of Arabia",
"tokens": [
"Lawrence",
"of",
"Arabia"]
}, {
"year": "1963",
"value": "Tom Jones",
"tokens": [
"Tom",
"Jones"]
}]
});
films.initialize();
$('.films .typeahead').typeahead(null, {
name: 'film',
displayKey: 'value',
source: films.ttAdapter()
})