The SearchDelay Option only delays after the first character

The SearchDelay Option only delays after the first character

amoliskiamoliski Posts: 2Questions: 1Answers: 0

Example case: Any server side processing table; searchDelay set to a high number (like 20000).

Expected: The search executes 20000 ms after you stop typing

Observed: The search runs after the first character is typed. After that the delay works as expected and it searches a second time 20000ms after the last character is typed

Cause: the _fnThrottle appears to run the function immediately, then delays subsequent function runs with a timeout that gets reset on each call.

This has a pretty big impact, because the first character of a search tends to take the longest to process as there are lots of matches. I think the old fnSetFilteringDelay() method worked with the desired behavior. Thoughts?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 52,624Questions: 1Answers: 8,049 Site admin
    Answer ✓

    Hi,

    To some degree this is actually by design - the function is a throttle rather than a debounce, so it is still limiting the input to a certain frequency, however, I fully take the point that you might expect the first call to happen at the end of the cycle, not the start. I will look into the best way of resolving this for the next release.

    Allan

  • amoliskiamoliski Posts: 2Questions: 1Answers: 0

    Thank you so much!

    I didn't want to clutter the OP with this, but I just wanted to say that working with your code has been an absolute pleasure. I've learned a lot about Javascript through studying how you implemented plugins and your general code structure.

  • allanallan Posts: 52,624Questions: 1Answers: 8,049 Site admin

    Its a real pleasure after a long day to read that. Thanks :-)

    Allan

  • logeloge Posts: 15Questions: 1Answers: 0

    +1 for the call at the end of the cycle. Would be a much better user experience.

This discussion has been closed.