typeahead.js: Unable to display more than 5 results with Bloodhound (0.11.1)

Hi there,

I’m using the version 0.11.1 of Typeahead.js with Bloodhound

I’m unable to display more than 5 results.

Here is my settings:

    var cityEngine = new Bloodhound({
            prefetch: './prefetch-cities.json',
            remote: {
                url: './search-cities.json?query=%QUERY',
                wildcard: '%QUERY'
            },
            sufficient: 20,
            identify: function(datum) {
                return datum.id;
            },
            datumTokenizer: function (datum) {
                return Bloodhound.tokenizers.whitespace(datum.name);
            },
            queryTokenizer: Bloodhound.tokenizers.whitespace
        });

I tried “limit” instead of “sufficient” (like in older versions) but it doesn’t work.

Prefetch is working fine. When I type in the input, for example I get instantly 2 results… then a remote request is done to get more results. I tried this request directly, and it returns 25+ results… but typeahead displays only 5.

Thank you.

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 19

Most upvoted comments

I faced same issue. limit:10 does not work for remote. but when I set limit:20, it does work. It is so strange typeahead parameter now.

did you try setting ‘limit’ in your dataset configuration? (which defaults to 5) see https://github.com/twitter/typeahead.js/blob/master/doc/jquery_typeahead.md#datasets

since 0.11 ‘limit’ is not a Bloodhound option anymore.

I think sufficient is the option again ( https://github.com/twitter/typeahead.js/blob/master/doc/bloodhound.md#options) but not to display items.

For me what worked is to set the limit property in the Data Source:

        var example_ds = {
            name: 'example',
            displayKey: 'Description',
            source: my_bloodhound_object,
            limit: 20
        };

+1. I’ve encountered same problem.

FWIW, I had to make sure that the limit was one less than the number of results being returned from my remote bloodhound object or nothing would show.