Skip to content

Instantly share code, notes, and snippets.

@jharding
Last active January 1, 2016 14:09
Show Gist options
  • Save jharding/8156058 to your computer and use it in GitHub Desktop.
Save jharding/8156058 to your computer and use it in GitHub Desktop.
<div class="example-sports">
<input class="typeahead" type="text" placeholder="NBA and NHL teams">
</div>
var nba = new Bloodhound({
datumTokenizer: function(d) { return Bloodhound.tokenizers.whitespace(d.team); },
queryTokenizer: Bloodhound.tokenizers.whitespace,
prefetch: '../data/nba.json'
});
var nhl = new Bloodhound({
datumTokenizer: function(d) { return Bloodhound.tokenizers.whitespace(d.team); },
queryTokenizer: Bloodhound.tokenizers.whitespace,
prefetch: '../data/nhl.json'
});
nba.initialize();
nhl.initialize();
$('.example-sports .typeahead').typeahead({
highlight: true
},
{
name: 'nba',
displayKey: 'team',
source: nba.ttAdapter(),
templates: {
header: '<h3 class="league-name">NBA Teams</h3>'
}
},
{
name: 'nhl',
displayKey: 'team',
source: nhl.ttAdapter(),
templates: {
header: '<h3 class="league-name">NHL Teams</h3>'
}
});
@josx
Copy link

josx commented Feb 21, 2014

hi @jharding!
I have forked your gist to match typeahead.js example.
Take a look https://gist.github.com/josx/9134760

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment