angular-strap icon indicating copy to clipboard operation
angular-strap copied to clipboard

Typeahead: delay ajax requests

Open zhenghao1 opened this issue 12 years ago • 14 comments

Hi,

This is more of a question than an issue as this project doesn't seem to have an IRC chat room.

I currently set a min-length of 1. However after that, if I were to type 5 more letters, it fires 5 ajax requests. I only want it to fire the ajax requests after a specified 1-2 seconds. Is such a feature possible? I know there's a delay feature, but the docs aren't really clear.

If a number is supplied, delay is applied to both hide/show

Is this a UI thing or is it really delaying the ajax requests?

zhenghao1 avatar May 07 '14 03:05 zhenghao1

I realized that minLength doesn't seem to work either. I am using Typeahead with an async data provider. Does that have anything to do with neither minLength nor delay having any effect?

zhenghao1 avatar May 07 '14 03:05 zhenghao1

I am experiencing the same issue at the moment. Both minLength and delay properties seem to be ignored.

tcfunk avatar May 29 '14 15:05 tcfunk

I believe the delay is just to delay the animation, not delay the actual firing of the request. I've manually tweaked my download of angular-strap to debounce the request, as per the details here: https://github.com/mgcrea/angular-strap/pull/696

M21B8 avatar Aug 05 '14 09:08 M21B8

You are absolutely correct, the delay is just for animation not the actual firing of the request. I find that really weird. It's as if the creators of this directive misunderstood the meaning of delay.

On Tue, Aug 5, 2014 at 5:33 PM, M21B8 [email protected] wrote:

I believe the delay is just to delay the animation, not delay the actual firing of the request. I've manually tweaked my download of angular-strap to debounce the request, as per the details here: #696 https://github.com/mgcrea/angular-strap/pull/696

— Reply to this email directly or view it on GitHub https://github.com/mgcrea/angular-strap/issues/749#issuecomment-51174179 .

zhenghao1 avatar Aug 06 '14 14:08 zhenghao1

I think it's just a slightly mis-clear labelling, should probably be called 'animation-delay'

M21B8 avatar Aug 06 '14 14:08 M21B8

I am also having the issue where promises are still called even if the minLength has not been met

codedroz avatar Sep 17 '14 15:09 codedroz

I have the same issue, but I suppose this is the same case as with the delay - the setting only affects visual elements, it doesn't affect async calls in the background.

mzgajner avatar Mar 04 '15 22:03 mzgajner

yes same issue here. +1 to fix the problem

smurugavel avatar Aug 28 '15 15:08 smurugavel

@mgcrea was there ever a PR for this? Yes you can use ngModelOptions on a per typeahead instance basis, but a global debounce for all typeaheads (via typeaheadProvider) would be really nice too!

axschech avatar Sep 02 '15 15:09 axschech

ngModelOptions doesn't serve the purpose, let's say I set the debounce in ngModelOptions to 300 ms, and I type 'test'... then 350 ms pause and 'ing'... what happens is two requests would be sent to server, first with 'test' and second with 'testing'. Now let's say the server responds the first request with some delay so that the result of 2nd query comes first and 1st query comes last... what will be shown in the autocomplete result is a set, matched with 'test' query which is wrong. Makes sense?

khashayar avatar Sep 02 '15 16:09 khashayar

@khashayar I was referencing this: https://github.com/mgcrea/angular-strap/pull/696

axschech avatar Sep 02 '15 16:09 axschech

It would be nice to have this documented.

joaoborsoi avatar Sep 16 '15 21:09 joaoborsoi

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jan 26 '19 04:01 stale[bot]

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

lock[bot] avatar May 05 '19 20:05 lock[bot]