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

Unnecessary AJAX request sent on hint autocomplete #1344

Open
bitcity opened this issue Aug 9, 2015 · 6 comments
Open

Unnecessary AJAX request sent on hint autocomplete #1344

bitcity opened this issue Aug 9, 2015 · 6 comments

Comments

@bitcity
Copy link
Contributor

bitcity commented Aug 9, 2015

In this example : http://twitter.github.io/typeahead.js/examples/#remote

If I type Chi, there's 1 network request and I see 1 suggestion i.e. Chicago. Now if I hit or Tab key to autocomplete the hint, there's another network request sent for Chicago. How can I avoid this ?

Probably related to #188 & #548

( I'll add that the reason isn't just to save on network requests. I have an app that dynamically updates the request URL and I want a better control over which requests are sent. In the above case, an automatic request is sent using a stale URL )

@marcocanderle
Copy link

I have the same kind of issue and it also happens when you select an option with the click of the mouse.

@MatthewReed
Copy link

If this could be useful, I had the same problem and was forced to change Typeahead autocomplete function commenting

this.input.setQuery(data.val);

row and adding a

this.menu.empty();

row.

@marcocanderle
Copy link

MatthewReed that might be a good solution but I can't modify the original library due to project policies. Thanks for your suggestion though!

Perhaps the authors could use that suggestion to fix the issue reported here?

@MatthewReed
Copy link

No, my solution is absolutely hack in that you can't view in your input field the single suggestion provided.
Unfortunately I had no time to study code in more depth to allow suggestion to pass without triggering ajac callback.

Matteo Rossi

----Messaggio originale----

Da: notifications@github.com

Data: 09/10/2015 22.21

A: "twitter/typeahead.js"typeahead.js@noreply.github.com

Cc: "MatthewReed"orionerossi@libero.it

Ogg: Re: [typeahead.js] Unnecessary AJAX request sent on hint autocomplete (#1344)

MatthewReed that might be a good solution but I can't modify the original library due to project policies. Thanks for your suggestion though!

Perhaps the authors could use that suggestion to fix the issue reported here?


Reply to this email directly or view it on GitHub.

@marcocanderle
Copy link

understood. Let's hope the authors can solve it soon then. thanks again!

Marco

@andre-rafa-b
Copy link

I used the MatthewReed solution but it didn't revolve my problem. Then I change it a little:
I didn't comment the line below. Instead of that I passed a second parameter called silent as true.
this.input.setQuery(data.val, true);
It isn't ready yet. The follow lines are also necessary:
this.menu.update(query);
this.close();

It solved the autocomplete event problem but it still occurs when the input field got focused. I will try to fix it another time. For now it fits me.

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

4 participants