Skip to content

Instantly share code, notes, and snippets.

@jharding
Last active January 1, 2016 14:09
Show Gist options
  • Save jharding/8156071 to your computer and use it in GitHub Desktop.
Save jharding/8156071 to your computer and use it in GitHub Desktop.
<div class="example-films">
<input class="typeahead" type="text" placeholder="best picture winner">
</div>
var films = new Bloodhound({
datumTokenizer: function(d) { return Bloodhound.tokenizers.whitespace(d.value); },
queryTokenizer: Bloodhound.tokenizers.whitespace,
remote: '../data/films/queries/%QUERY.json',
prefetch: '../data/films/post_1960.json'
});
films.initialize();
$('.example-films .typeahead').typeahead(null, {
displayKey: 'value',
source: films.ttAdapter(),
templates: {
suggestion: Handlebars.compile(
'<p><strong>{{value}}</strong> – {{year}}</p>'
)
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment