Ajay Jangra
Ajay Jangra

Reputation: 174

datatable search field always focus stop all other action

my datatable search field focus always ,but it stop all other action ,is it possible that focus reamin in search field and other action also work ?

my code for focus is as

var table = $('#datatable').dataTable({   
           "bJQueryUI": true,           
           "stateSave": false,                      
           "bProcessing": true,
           "order": [[ 0, "desc" ]],
           "aLengthMenu": [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]],
           "iDisplayLength": -1
        });
        $('#datatable_filter input').focus()

        $('#datatable_filter input').on('blur', function(){
         $('#datatable_filter input').focus() 
        }); 

i also try timeout that not work

$('#datatable_filter input').on('blur', function () { 
        setTimeout(function () { $('#datatable_filter input').focus(); }, 1000);
         }); 

Upvotes: 0

Views: 1266

Answers (3)

Khusbhoo Garg
Khusbhoo Garg

Reputation: 79

you can set focus in field on window.focus() as:

    $(window).on('focus', function(){
     $('#datatable_filter input').focus() 
    });

Upvotes: 2

Ajay Jangra
Ajay Jangra

Reputation: 174

i found my answer and it work for me

$('#datatable_filter input').focus()
        $(window).on('focus', function(){
         $('#datatable_filter input').focus() 
        });

Upvotes: 1

shubhangee
shubhangee

Reputation: 539

Give a try with this code to focus search box

$('div.dataTables_filter input').focus(); 

Upvotes: 0

Related Questions