Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Typeahead: Uncaught Error Missing source

I am getting this error in console everytime I try to run the following code

$('#autcomplete_search').typeahead({
  highlight: true
},
{
  name: 'apple_game',
  remote: "/search/autocomplete?keyword=make"
});
like image 447
user2158382 Avatar asked Mar 06 '14 01:03

user2158382


1 Answers

Typeahead: Uncaught Error Missing source

If fetching remote, you need to specify the engine. Here is an example from the docs

var bestPictures = new Bloodhound({
  datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'),
  queryTokenizer: Bloodhound.tokenizers.whitespace,
  prefetch: '../data/films/post_1960.json',
  remote: '../data/films/queries/%QUERY.json'
});

bestPictures.initialize();

$('#remote .typeahead').typeahead(null, {
  name: 'best-pictures',
  displayKey: 'value',
  source: bestPictures.ttAdapter()
});

in this example, var bestPictures is your engine

bloodhound documentation

like image 97
lfender6445 Avatar answered Oct 22 '22 23:10

lfender6445