When using twitter typeahead.js, it typically returns elements that match only at the beginning of a string. For example:
source: ['type','typeahead','ahead']
query: 'type'
Returns: 'type' and 'typeahead'
--
query: 'ahead'
Returns: 'ahead'
However, I would like it to also return 'ahead' and 'typeahead'
This is the code I have written for it:
var clients = new Bloodhound({
datumTokenizer: function(d) { return Bloodhound.tokenizers.whitespace(d.value); },
queryTokenizer: Bloodhound.tokenizers.whitespace,
limit: 10,
prefetch: {
url: '/clients.json',
filter: function(list) {
return $.map(list, function(value) { return { name: value }; });
}
}
});
clients.initialize();
$('.client').typeahead(null, {
displayKey: 'value',
source: clients.ttAdapter(),
minLength: 1,
});
I have found a similar question regarding this issue, but the answer provided was difficult for me to understand.