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

Dynamic Ajax GET query with NO delay wont generate dropdown list some times #248

Closed
seltix5 opened this Issue Oct 22, 2016 · 13 comments

Comments

Projects
None yet
3 participants
@seltix5
Contributor

seltix5 commented Oct 22, 2016

hi,
great plugin first of all!
i want o have a search field with instant dynamic autocomplete but it is not working correctly. with delay it works nice but it is not really a good option because the user need to stop write. i wold like to have the dropdown autocomplete list updating has the user type each letter, and because of that i set the delay to a value like 0 or even 100 ms.

apparently because of that the var "generatedGroupCount" is not always set to 0 and because of that in first check on the "incrementGeneratedGroup" function the process stop and the suggestions list is not updated.

i just comment the "return;" on line 1273 (jquery-typeahead-2.7.1/src/jquery.typeahead.js -> function incrementGeneratedGroup) and now it works but maybe this wold cause problems elsewhere?

any idea about this?

thanks :D

@seltix5 seltix5 changed the title from . to Dynamic Ajax GET query with NO delay wont generate dropdown list some times Oct 22, 2016

@mitosch

This comment has been minimized.

mitosch commented Oct 25, 2016

+1

I analysed the behaviour and it fails to load the list, after one json request was canceled. See example:
image

In this example, the delay was set to 100.

I'm trying to debug it further, but I'm now stuck at the jquery code at deferred.fail() http://api.jquery.com/deferred.fail/

@seltix5

This comment has been minimized.

Contributor

seltix5 commented Oct 25, 2016

hi,
this is in chrome right? how do i get this requests listed?

about the problem, i think because there are made multiple requests too quickly, the previous one is canceled by jquery (im just guessing)...

apparently the problem is "populateSource()" is run anyway and "this.generatedGroupCount" is incremented. after that the last request works but because "this.generatedGroupCount" as a wrong count the dropdown is not populated.

possible solution... on fail the "populateSource()" should not execute?

@mitosch

This comment has been minimized.

mitosch commented Oct 25, 2016

Hi

Yes, Chrome. Left mouse button -> inspect element -> network.

Ok. I'll take a look at it, but I need to dig into jquery.typeahead source.

@seltix5

This comment has been minimized.

Contributor

seltix5 commented Oct 25, 2016

Yes i did check on the network tab but i dont get the GET requests from typeahead listed :s strange...

@mitosch

This comment has been minimized.

mitosch commented Oct 25, 2016

Are you using ajax as a source for typeahead?

I just tested one thing. By removing the line 714, the calls won't get aborted:

            if (!this.helper.isEmpty(this.xhr)) {
                for (var i in this.xhr) {
                    if (!this.xhr.hasOwnProperty(i)) continue;
                    //this.xhr[i].abort();
                }
                this.xhr = {};
            }

No clue about the side effects.

@seltix5

This comment has been minimized.

Contributor

seltix5 commented Oct 25, 2016

so, i was wrong, the abort really is requested on the code... humm

running-coder added a commit that referenced this issue Oct 25, 2016

@running-coder

This comment has been minimized.

Owner

running-coder commented Oct 25, 2016

Hey guys, I was able to reproduce the issue. Populate was called with invalid data (aborted requests) let me know if this fix resolved the issue.

@running-coder running-coder added the Bug label Oct 25, 2016

@running-coder running-coder added this to the 2.7.2 milestone Oct 25, 2016

running-coder added a commit that referenced this issue Oct 25, 2016

running-coder added a commit that referenced this issue Oct 25, 2016

running-coder added a commit that referenced this issue Oct 26, 2016

Version 2.7.2
Fix #243 On form reset, hide the result list
Fix #248 Dynamic Ajax GET query would not generate dropdown list when aborted
Fix #249 Fix the Click action when `options.href` is defined
@mitosch

This comment has been minimized.

mitosch commented Oct 29, 2016

Thank you, I'll check it out in the upcoming days.

Btw: Thanks for the cool plugin, great work!

@seltix5

This comment has been minimized.

Contributor

seltix5 commented Oct 29, 2016

hi! thank you.

it is working for me now, i dint detect any problem now, thanks :D

@running-coder

This comment has been minimized.

Owner

running-coder commented Oct 29, 2016

can't beleive the issue has been there for so long, thanks for reporting it guys

@seltix5

This comment has been minimized.

Contributor

seltix5 commented Oct 29, 2016

no problem, your'e doing a great job! congrats :D

@mitosch

This comment has been minimized.

mitosch commented Oct 30, 2016

Hi

I can also confirm that the bug is fixed.

Thank you!

@seltix5

This comment has been minimized.

Contributor

seltix5 commented Feb 20, 2017

hi, i update my version to the last one and i noticed a bug where it does not generate the dropdown list. this ocurs when i write too fast.
for example with the dynamic mode for countries list and a 100 ms delay, if i type "portugal" fast the dropdown wont update and will show "no options found".
do you have a sandbox mode to isolate the problem? i havethis online right now if you want the link to check it.
Thanks.

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