what happens when you hit enter after typing something in the search bar of a datatable.
what happens when you hit enter after typing something in the search bar of a datatable.
I have come across an old php based website that is using the datatable script to display some data. when you type something in the search bar of the datatable, it sends an ajax request and filters the results based on the input string, when you press enter, it reloads the same webpage, with the entire table. I want it to filter out the data when enter is hit also. Is there a way to control what the search functionality does on hitting enter? I am not very familiar with either of php and jquery datatable to so any help here would be appreciated.
Thanks.
Answers
Here is the code (for one fo the pages of the website):
I don't know why it would be doing that. You don't say what version of DataTables you are using, but there is no version that should be resulting in a page reload when the enter key is pressed at that point.
We introduced
search.return
in 1.11 to delay search until the enter key is pressed, but that doesn't sounds like what you are seeing. Pehaps your DataTable is inside a<form>
and that is triggering the submit? Without a test case it is impossible to say, and it sounds like you might be using an old unsupported version of DataTables.Allan