twitter / typeahead.js

typeahead.js is a fast and fully-featured autocomplete library
http://twitter.github.io/typeahead.js/
MIT License
16.52k stars 3.21k forks source link

Multiple Datasets not working and header name not displaying in typeahead.js #866

Closed Sushreddy27 closed 10 years ago

Sushreddy27 commented 10 years ago

Hi, i am trying to use typeahead with multiple datasources but my results show up from only one data set. below is my typeahead code
$('#multiSearch').typeahead({
name: 'consumer name', source: function (request, response) { $.get("/Search/api/SearchByName/?name=" + request + '&isAutoComplete=' + true, function (LookUpNames) { return response(LookUpNames); }) }, templates: { header: '

NBA Teams

' } }, { name: 'nhl', displayKey: 'team', source: ['Unites States', 'Mexico', 'Canada', 'Cuba', 'Guatemala'], templates: { header: '

NHL Teams

' } } ); It only fetches data from 1st data source but not the second one. Also i am unable to see the header name displaying when suggested results come up. What am i missing?

jharding commented 10 years ago

2 things:

  1. Headers and footers will only appear if there's data for their respective dataset.
  2. A source must be a function (your second dataset is passing in an array). See the docs for more details.