Last active
January 1, 2016 14:09
-
-
Save jharding/8156058 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="example-sports"> | |
<input class="typeahead" type="text" placeholder="NBA and NHL teams"> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>' | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hi @jharding!
I have forked your gist to match typeahead.js example.
Take a look https://gist.github.com/josx/9134760