I am using typeahead.js and everything works fine for me, except one thing:
I display only 5 entries in the suggestion dropdown, but if there are more results, I would like to show the user, that there are more results (but not the results itself, just the info, that there are more results) so that he goes on typing.
Please see screen attached.
You can use a filter that just pulls out the length. In this example, only 20 results would be shown but I wanted people to know if there were more results not being displayed. See this for putting the results in a footer.
var addresses = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('number'),
queryTokenizer: Bloodhound.tokenizers.whitespace,
limit: 20,
remote: {
url: 'url?q=%QUERY',
filter: function(list) {
$('#search-total').html(list.length);
return list;
}
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With