Last active
April 2, 2025 21:04
-
-
Save jharding/9458797 to your computer and use it in GitHub Desktop.
Example for http://twitter.github.io/typeahead.js/examples/.
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
#multiple-datasets .league-name { | |
margin: 0 20px 5px 20px; | |
padding: 3px 0; | |
border-bottom: 1px solid #ccc; | |
} |
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 id="multiple-datasets"> | |
<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 nbaTeams = new Bloodhound({ | |
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('team'), | |
queryTokenizer: Bloodhound.tokenizers.whitespace, | |
prefetch: '../data/nba.json' | |
}); | |
var nhlTeams = new Bloodhound({ | |
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('team'), | |
queryTokenizer: Bloodhound.tokenizers.whitespace, | |
prefetch: '../data/nhl.json' | |
}); | |
$('#multiple-datasets .typeahead').typeahead({ | |
highlight: true | |
}, | |
{ | |
name: 'nba-teams', | |
display: 'team', | |
source: nbaTeams, | |
templates: { | |
header: '<h3 class="league-name">NBA Teams</h3>' | |
} | |
}, | |
{ | |
name: 'nhl-teams', | |
display: 'team', | |
source: nhlTeams, | |
templates: { | |
header: '<h3 class="league-name">NHL Teams</h3>' | |
} | |
}); |
You can find the nba.json file here : https://github.com/twitter/typeahead.js/blob/gh-pages/data/nba.json
and the nhl.json file here : https://github.com/twitter/typeahead.js/blob/gh-pages/data/nhl.json
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, I wonder where can i find the dataset :
../data/nba.json
and../data/nhl.json
. ? Thanks