Skip to content

Instantly share code, notes, and snippets.

@jharding
Last active January 1, 2016 14:09
Show Gist options
  • Save jharding/8156031 to your computer and use it in GitHub Desktop.
Save jharding/8156031 to your computer and use it in GitHub Desktop.
<div class="example-countries">
<input class="typeahead" type="text" placeholder="countries">
</div>
var countries = new Bloodhound({
datumTokenizer: function(d) { return Bloodhound.tokenizers.whitespace(d.name); },
queryTokenizer: Bloodhound.tokenizers.whitespace,
limit: 10,
prefetch: {
url: '../data/countries.json',
filter: function(list) {
return $.map(list, function(country) { return { name: country }; });
}
}
});
countries.initialize();
$('.example-countries .typeahead').typeahead(null, {
name: 'countries',
displayKey: 'name',
source: countries.ttAdapter()
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment