I'm trying to use Bootstrap 3's Typeahead script to auto populate an airport lookup.
This is the web service I am trying to use: http://airportcode.riobard.com/about#about
I've modified another working jsfiddle (original working source and array key commented out and replaced with new ones)
// instantiate the bloodhound suggestion engine
var airports = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'),
queryTokenizer: Bloodhound.tokenizers.whitespace,
remote: {
//url: 'http://api.themoviedb.org/3/search/movie?query=%QUERY&api_key=470fd2ec8853e25d2f8d86f685d2270e',
url: 'http://airportcode.riobard.com/search?q=%QUERY&fmt=JSON',
filter: function (airports) {
return $.map(airports.results, function (airport) {
return {
//value: airport.title
value: airport.name
};
});
}
}
});
// initialize the bloodhound suggestion engine
airports.initialize();
// instantiate the typeahead UI
$('.typeahead').typeahead(null, {
name: 'airports',
displayKey: 'value',
source: airports.ttAdapter()
});
http://jsfiddle.net/UkB7u/109/
Not sure why it's not working, as far as I can tell it should work as is but it doesn't.