Skip to content

Instantly share code, notes, and snippets.

@jharding
Last active January 1, 2016 14:09
Show Gist options
  • Save jharding/8156044 to your computer and use it in GitHub Desktop.
Save jharding/8156044 to your computer and use it in GitHub Desktop.
<div class="example-twitter-oss">
<input class="typeahead" type="text" placeholder="open source projects by Twitter">
</div>
var repos = new Bloodhound({
datumTokenizer: function(d) { return d.tokens; },
queryTokenizer: Bloodhound.tokenizers.whitespace,
prefetch: '../data/repos.json'
});
repos.initialize();
$('.example-twitter-oss .typeahead').typeahead(null, {
name: 'twitter-oss',
displayKey: 'name',
source: repos.ttAdapter(),
templates: {
suggestion: Handlebars.compile([
'<p class="repo-language">{{language}}</p>',
'<p class="repo-name">{{name}}</p>',
'<p class="repo-description">{{description}}</p>'
].join(''))
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment