Typeahead js导致另一个div

时间:2014-02-18 20:30:40

标签: javascript jquery typeahead typeahead.js twitter-typeahead

我正在使用typeahead.js v0.10.1,我想知道是否有办法让搜索结果出现在另一个div而不是下拉列表中?

http://jsfiddle.net/qLk8c/14/

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()
 })

0 个答案:

没有答案