How do I get searchDelay to apply to a string replace on .dataTables_filter input?
How do I get searchDelay to apply to a string replace on .dataTables_filter input?
Test case: http://live.datatables.net/nefewovi/1/edit
Here you can see that writing "tiger" in the search box, replaces that search term with the word "sonya" instead, bringing up the results of sonya immediately. This happening immediately is one problem.
Yet with searchDelay applied, the results go back to "tiger" after 3 seconds. Which is another problem.
Now while this table is small, a huge dataset would lag if search ran immediately on every keypress. Therefore I would expect searchDelay to throttle the filter. How do I get that to work here?
Thanks.
This question has an accepted answers - jump to answer
Answers
Due to calling
search()
in yourkeyup
event. This is outside the search Datatables is using for the search input.searchDelay
doesn't affect searching via the APIs.Change the input value to
sonya
.Something like this:
http://live.datatables.net/nefewovi/2/edit
If using
searchDelay
doesn't behave the way you like you might need to create a debounce function. See this thread for some ideas.Kevin