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

Remote completion #1218

Open
Stnaire opened this issue May 7, 2015 · 43 comments

Comments

@Stnaire
Copy link

commented May 7, 2015

I have a very strange behavior with remote data.
I've made a self explaining JSFiddle that you can find here.

It works well with 1 result, or two, or more than 5. Otherwise it's completly messed up.

@Stnaire

This comment has been minimized.

Copy link
Author

commented May 7, 2015

I've made a small modification to the source of typeahead.js because I need this thing to work as soon as possible.

The problem comes from "typeahead.bundle.js:1719" :

function async(suggestions) {
    suggestions = suggestions || [];
    if (!canceled && rendered < that.limit) {
        that.cancel = $.noop;
        rendered += suggestions.length;
        that._append(query, suggestions.slice(0, that.limit - rendered));
        that.async && that.trigger("asyncReceived", query);
    }
}

I've replaced :

rendered += suggestions.length;
that._append(query, suggestions.slice(0, that.limit - rendered));

by :

suggestions = (suggestions || []).slice(0, that.limit);
rendered = suggestions.length;
that._append(query, suggestions);

and it seems to work.. I have no idea of possible side effects of this modification, so I hope someone with enough knowledge of the library can check this.

@joekur

This comment has been minimized.

Copy link

commented May 7, 2015

+1 came here with the same issue and general conclusion

@hartwoolery

This comment has been minimized.

Copy link

commented May 7, 2015

+1

@DutchEcho

This comment has been minimized.

Copy link

commented May 8, 2015

I got the same issue. I have added your code to the JS. However it still shows only 5 out of ten search results but now atleast it shows all results up to 5 instead of sometimes 2 out of 3.

Any workaround to let it show all 10 results from bloodhound?

@joekur

This comment has been minimized.

Copy link

commented May 8, 2015

This is the code I used to replace the aforementioned 2 lines (small difference to account for already rendered suggestions):

suggestions = suggestions.slice(0, that.limit - rendered);
rendered += suggestions.length;
that._append(query, suggestions);

I'll see if I can get a pull with a corresponding test up today.

@DutchEcho did you set the limit option to 10? The default is 5.

@DutchEcho

This comment has been minimized.

Copy link

commented May 8, 2015

Gues the limit is new as it worked before. I have added limit: 10 now in my typeahead and it works like a charm again. Thanks @joekur

@ZaneCEO

This comment has been minimized.

Copy link

commented May 21, 2015

Hi guys, I found this report Googling around. Could you kindly take a look at this http://stackoverflow.com/questions/30370496/typeahead-js-bloodhound-display-just-one-result and confirm me that the problem I've is due to this bug? Otherwise I'll open a new bug since I cannot find any other cause here..

@ZaneCEO

This comment has been minimized.

Copy link

commented May 21, 2015

Confirmed! I applied @joekur suggested workaround and the issue is gone... I hope this will be fixed soon on the official package!

@jarthod

This comment has been minimized.

Copy link

commented May 26, 2015

I also got this issue, the fix is in #1212 but hasn't been merged yet.

@jarthod

This comment has been minimized.

Copy link

commented May 26, 2015

Duplicate of #1185

kevinbarnett pushed a commit to getyourguide/typeahead.js that referenced this issue Aug 4, 2015

@0x62

This comment has been minimized.

Copy link

commented Sep 3, 2015

Bumping, this is still open and unfixed.

@ChrisWoodlief

This comment has been minimized.

Copy link

commented Oct 3, 2015

The fix has still not been merged

@ivalexa

This comment has been minimized.

Copy link

commented Oct 5, 2015

+1 There is still bug in current version !!!

@goyote

This comment has been minimized.

Copy link

commented Oct 7, 2015

Just wasted a whole day trying to get remote to work thinking there was something bad with my code, can you guys fix your shit? @jharding The solution has already been given to you, just merge it

@jarthod

This comment has been minimized.

Copy link

commented Oct 7, 2015

Twitter abandonned the project, here is a maintained fork with the fix merged: https://github.com/corejavascript/typeahead.js

@rosskevin

This comment has been minimized.

Copy link

commented Oct 16, 2015

I actually didn't have to replace the code, only add limit:10 to typeahead and my results started showing. So far so good. Thanks for the pointer @jarthod, I'll look to that repo.

@outaTiME

This comment has been minimized.

Copy link

commented Dec 3, 2015

+1

@JustinWinthers

This comment has been minimized.

Copy link

commented Dec 12, 2015

+1 - that last bit of code posted by @joekur fixed my issue of typeahead chopping off the last suggestion when 5 or less suggestions were returned by my api & bloodhound. Thank you!

@JustinWinthers

This comment has been minimized.

Copy link

commented Dec 12, 2015

+1 to @Stnaire for posting the original code.

@maxaudrin

This comment has been minimized.

Copy link

commented Dec 17, 2015

+1

@jiri-jagos

This comment has been minimized.

Copy link

commented Dec 22, 2015

@andrewgunn

This comment has been minimized.

Copy link

commented Jan 19, 2016

+1

@delphiki

This comment has been minimized.

Copy link

commented Jan 19, 2016

Same problem here, +1

@Abhith

This comment has been minimized.

Copy link

commented Jan 20, 2016

+1

1 similar comment
@maior-valentin

This comment has been minimized.

Copy link

commented Jan 28, 2016

+1

@xrnm

This comment has been minimized.

Copy link

commented Jan 28, 2016

+1

@maior-valentin

This comment has been minimized.

Copy link

commented Jan 29, 2016

@xrnm I solved the issue by taking the version from corejavascript forked version.

@lologhi

This comment has been minimized.

Copy link

commented Feb 1, 2016

+1

@Doopin

This comment has been minimized.

Copy link

commented Mar 14, 2016

Same problem here...
+1 @rosskevin his solution works

@lologhi

This comment has been minimized.

Copy link

commented Mar 14, 2016

Maybe it's time to stop using this no more maintained library. For my usage, Select2 was enough. Otherwise you can also try awesomplete.

e-dot added a commit to e-dot/bcdlibre that referenced this issue Jun 1, 2016

@stavBodik

This comment has been minimized.

Copy link

commented Jun 4, 2016

This fix works , just somthing if you have no limit set you should use :
suggestions = (suggestions || []).slice(0, that.limit+1);

@maczor

This comment has been minimized.

Copy link

commented Dec 8, 2016

+1

8 similar comments
@stimcon-dev

This comment has been minimized.

Copy link

commented Dec 26, 2016

+1

@dani-mezo

This comment has been minimized.

Copy link

commented Jan 6, 2017

+1

@aleangelico

This comment has been minimized.

Copy link

commented Jan 16, 2017

+1

@martch

This comment has been minimized.

Copy link

commented Feb 16, 2017

+1

@lewis-spears

This comment has been minimized.

Copy link

commented Mar 6, 2017

+1

@const-z

This comment has been minimized.

Copy link

commented Apr 1, 2017

+1

@rmmoriya

This comment has been minimized.

Copy link

commented Apr 18, 2017

+1

@kaarelr

This comment has been minimized.

Copy link

commented May 18, 2017

+1

@rikosage

This comment has been minimized.

Copy link

commented Jun 19, 2017

+1, thx for this fix

@stavBodik

This comment has been minimized.

Copy link

commented Oct 24, 2017

(:

@vanzaraitama

This comment has been minimized.

Copy link

commented Nov 13, 2017

+1

hlcfan added a commit to hlcfan/pokr that referenced this issue Mar 13, 2018

jbothma added a commit to OpenUpSA/biz-portal that referenced this issue Jul 3, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.