Created
November 18, 2014 10:03
-
-
Save anonymous/85acdb6b2679af1cd781 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// In our DOM ready | |
var poets = new Bloodhound({ | |
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'), | |
queryTokenizer: Bloodhound.tokenizers.whitespace, | |
limit:10, | |
prefetch: { | |
// url points to a json file that contains an array of poet names | |
// e.g. ['Baudelaire', 'Beckett'] | |
url: './poets.json', | |
filter: function(list){ | |
return $.map(list, function(poet) { return { name: poet }; }); | |
} | |
} | |
}); | |
var philosophers = new Bloodhound({ | |
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'), | |
queryTokenizer: Bloodhound.tokenizers.whitespace, | |
limit:10, | |
prefetch: { | |
// url points to a json file that contains an array of philosopher names | |
// e.g. ['Descartes', 'Derrida'] | |
url: './philosophers.json', | |
filter: function(list){ | |
return $.map(list, function(philosopher) { return { name: philosopher }; }); | |
} | |
} | |
}); | |
poets.initialize(); | |
philosophers.initialize(); | |
$('#multiple-datasets .typeahead').typeahead({ | |
highlight: true | |
}, | |
{ | |
name: 'poets', | |
displayKey: 'name', | |
source: poets.ttAdapter(), | |
templates: { | |
header: '<h3 class="league-name">Poets</h3>' | |
} | |
}, | |
{ | |
name: 'philosophers', | |
displayKey: 'name', | |
source: philosophers.ttAdapter(), | |
templates: { | |
header: '<h3 class="league-name">Philosophers</h3>' | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment