I am having trouble getting the default Twitter typeahead custom template working found here: http://twitter.github.io/typeahead.js/examples/#custom-templates I am able to get the default demo working just fine. Here is my js code
jQuery(document).ready(function() {
var bestPictures = [
{"year": "1996", "value": "Tom", "url": "http://example.com"},
{"year": "1998", "value": "Tim", "url": "http://example.com"}
];
$('#custom-templates .typeahead').typeahead(null, {
name: 'best-pictures',
display: 'value',
source: bestPictures,
templates: {
empty: [
'<div class="empty-message">',
'unable to find any Best Picture winners that match the current query',
'</div>'
].join('\n'),
suggestion: Handlebars.compile('<div><strong>{{value}}</strong> – {{year}}</div>')
}
});
});
I couldn't find the source code of the example in where they get bestPictures
from. I also have handlebars installed. When I type in the letter t
into the search box, my console log shows this.source is not a function
in typeahead.bundle.js
on this line: this.source(query, sync, async);
Additionally, I would like to do a redirect once a dropdown option is selected, similar to
on('typeahead:selected', function(event, datum) {
window.location = datum.url
});