1.10.3 searchDelay not working properly
1.10.3 searchDelay not working properly
Hi,
I was waiting for this release because I read it was going to include the searchDelay option which I needed (and I prefer not to workaround), so of course I immediately downloaded it when it was released.
However, I've added searchDelay: 3000 to my datatable init but it doesnt seem to work properly. It appears the timer is not reset on each keypress.
If I type very slowly (like 1 char per second), the draw is performed mid-typing.
You can test it here: http://live.datatables.net/sikexizi/2/edit
Just type any data from the table very slowly.
This question has an accepted answers - jump to answer
Answers
This is correct and intentional. I thought I'd put a point about this in the documentation, but apparently not (I'll add it) - the
searchDelay
uses a throttle, not a debouce. So the search is triggered a maximum of once in the time specified and will be called at the end of that period, always. The counter is intentionally not reset on each call.If that is something that you want you would need to either have your own input box or detach DataTables' default event listener and add your own with a key debounce.
Allan
Thanks.
Can you give me a quick code snippet to show how to cancel the search event?
This does not work for me:
and neither does this:
Use
$().off()
to remove it:Allan
off() doesn't seem to work for me.
I tried with my own css selector, confirmed it is correct in the debugger but the search still happens.
Any ideas?
Sorry - it should be
keyup.dt
.Allan
Keyup.dt does not work either.
Search is still performed.
One more try :-)
Example: http://live.datatables.net/topeyeqi/1/edit
Allan
The keyup.DT and input.DT combo did it :)
For anyone with the same problem, here's what I did:
Replace tables[0] with the instance of your DataTable.
Thanks for the help Allan :)
Edit: sorry, cant seem to get the code to display in a normal way :x
Nice - thanks for sharing with us!
Allan