Datatbles - Custom Search not working
Datatbles - Custom Search not working
Noodles12
Posts: 113Questions: 41Answers: 2
I have added a Custom Search to a page that uses Datatables. The custom search works on live.datatables.net, but not on my local system. Here is my code - https://live.datatables.net/jebatava/1/edit
$('#myInputTextField').on( 'keyup', function () {
table.search( this.value ).draw();
});
As you can see "myInputTextField" works well here, but it does not work in my environment. Any ideas what could be the reason? Thanks.
This question has an accepted answers - jump to answer
Answers
The test case has this error causing the search to not work:
You are creating the
table
variable within the context of the document.ready() function. But your event handler is outside of this function so it doesn't have access to thetable
variable. Move the event handler inside the document.ready() function:https://live.datatables.net/jebatava/2/edit
Now this error:
We need to create the filtered variable.
With these fixes the test case runs. If this doesn't help with your issue then check the browser's console for errors.
Kevin
That did it. Thankyou very much!!