autofocus input search

autofocus input search

FlavioC16FlavioC16 Posts: 3Questions: 1Answers: 0
edited July 2022 in Free community support

I would like to implement the "autofocus" function in the search field of my table, is this possible?

Answers

  • ItracItrac Posts: 12Questions: 1Answers: 0

    Check out this thread, especially Kevin's answer with the initComplete example.

  • FlavioC16FlavioC16 Posts: 3Questions: 1Answers: 0

    Thanks for replying, but I'm new in the area, this type of code "initComplete" is not working in httm5 in conjunction with javascript :(

  • kthorngrenkthorngren Posts: 20,149Questions: 26Answers: 4,736

    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

  • FlavioC16FlavioC16 Posts: 3Questions: 1Answers: 0

    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)
    });

Sign In or Register to comment.