Skip to content

Hints not shown when limit equals count of nodes in dataset #1661

@alexandrahrastnik

Description

@alexandrahrastnik

Hi there!
In our web application we use typeahead.js to give hints for item id's. Works fine as long as there are more than five (5) items in the dataset with hints. But when there are exactly five or less items to show, the results aren't the expected ones.

As datasource we use a Bloodhound object with Remote (without Prefetch).

When you search for "at90v" our program returns the following list:

["AT90V10","AT90V100","AT90V12","AT90V15","AT90V15/12","AT90V20","AT90V20/12","AT90V20/15","AT90V25","AT90V25/15","AT90V25/20"]

and typeahead.js shows the first five items (as expected).
But when you search for "at90v1" (one character more), our program returns the following list:

["AT90V10","AT90V100","AT90V12","AT90V15","AT90V15/12"]

and typeahead.js shows zero hints.
I also tried to modify our program always to return only five items, but then typeahead.js completely stopped working.

Following the most important code snippets from our JavaScript file where typeahead.js is initialized.
You can find the full JavaScript file here: holterOnline.app.js (used in combination with holterOnline.lib.js).

dataSource = new Bloodhound({ datumTokenizer: Bloodhound.tokenizers.whitespace, queryTokenizer: Bloodhound.tokenizers.whitespace, remote: { url: programmAufruf + '&SUCHBEGR=%QUERY', wildcard: '%QUERY', transform: formatiereDaten } });
$elem.typeahead({ hint: false, highlight: true, minLength: 1 }, { name: 'dsTypeahead' + pgmn, source: dataSource });
var formatiereDaten = function (response) { response.forEach(function (element, index, array) { array[index] = decodeURIComponent(element); }); return response; };

Issue #1653 was about the same topic, but was closed without being fixed.
I tried to fix this bug on my own (Pull requests #1659 and #1660 ) but I made something wrong - the Travis CI build failed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions