Last active
August 29, 2015 13:55
-
-
Save jharding/8764233 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-numbers"> | |
<input class="typeahead" type="text" placeholder="numbers (one through ten)"> | |
</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
// instantiate the bloodhound suggestion engine | |
var numbers = new Bloodhound({ | |
datumTokenizer: function(d) { return Bloodhound.tokenizers.whitespace(d.num); }, | |
queryTokenizer: Bloodhound.tokenizers.whitespace, | |
local: [ | |
{ num: 'one' }, | |
{ num: 'two' }, | |
{ num: 'three' }, | |
{ num: 'four' }, | |
{ num: 'five' }, | |
{ num: 'six' }, | |
{ num: 'seven' }, | |
{ num: 'eight' }, | |
{ num: 'nine' }, | |
{ num: 'ten' } | |
] | |
}); | |
// initialize the bloodhound suggestion engine | |
numbers.initialize(); | |
// instantiate the typeahead UI | |
$('.example-numbers .typeahead').typeahead(null, { | |
displayKey: 'num', | |
source: numbers.ttAdapter() | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment