autofocus input search
autofocus input search
FlavioC16
Posts: 3Questions: 1Answers: 0
I would like to implement the "autofocus" function in the search field of my table, is this possible?
Answers
Check out this thread, especially Kevin's answer with the initComplete example.
Thanks for replying, but I'm new in the area, this type of code "initComplete" is not working in httm5 in conjunction with javascript
Please provide a link to your page or a test case showing the problem so we can help debug. You can update my below example.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Allan's solution in that thread works here:
http://live.datatables.net/puxafaga/1/edit
Kevin
Thanks for helping with this issue, the issue was resolved this way.
$(document).ready( function () {
var table = $('#dataTable').DataTable();
function foco(){
$('div.dataTables_filter input', table.table().container()).focus();
}
setTimeout(foco, 1)
});
Does not work with version 2. Does anyone here have a solution?
@djmcm
I opened the test case I linked to above:
http://live.datatables.net/puxafaga/1/edit
And its working. Its using the Datatable nightly version which are the builds leading up to the next 2.x version. If this doesn't work for you then please post a link to a test case showing the issue. Possibly put the code in the
ready()
function so it executes after Datatables is fully ready.Kevin