Last active
August 29, 2015 14:05
-
-
Save elsapet/153978788aa4d70ac5b0 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 author 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