Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
patrickhrastnik opened this issue Jul 30, 2017 · 1 comment
Closed

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

patrickhrastnik opened this issue Jul 30, 2017 · 1 comment

Comments

@patrickhrastnik
Copy link

patrickhrastnik commented Jul 30, 2017

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.

patrickhrastnik added a commit to HolterDev/typeahead.js that referenced this issue Jul 30, 2017
I think this might be a valid solution for twitter#1661 (and twitter#1653 )
@patrickhrastnik
Copy link
Author

See #1662 - issue fixed, Travis CI passed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant