Skip to content

Instantly share code, notes, and snippets.

@jharding
Last active August 29, 2015 13:55
Show Gist options
  • Save jharding/8764233 to your computer and use it in GitHub Desktop.
Save jharding/8764233 to your computer and use it in GitHub Desktop.
<div class="example-numbers">
<input class="typeahead" type="text" placeholder="numbers (one through ten)">
</div>
// 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