2

airports.js contains the following data structure:

[{"code": "LGW", "name": "Gatwick Airport", "location": "London, UK"}, {"code": "LHR", "name": "Heathrow Airport", "location": "London, UK"}]

A search for 'Gatwick' returns the following result: 'LGW - Gatwick Airport'.

Searches for 'LGW' or 'London' return no results.

var airports = new Bloodhound({
    datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),
    queryTokenizer: Bloodhound.tokenizers.whitespace,
    limit: 10,
    prefetch: '/data/airports.js'
});
airports.initialize();

$('.typeahead').typeahead(null, {
    source: airports.ttAdapter(),
    templates: {
        suggestion: Handlebars.compile('<span>{{code}} - {{name}}</span>')
    }
});

I would like to search all keys: code, name and location but can't figure out how to do that, any ideas?

Andy
  • 454
  • 2
  • 7
  • 22

0 Answers0