Prevent input field on editable datatable from going out of focus when ajax setInterval is triggered

Prevent input field on editable datatable from going out of focus when ajax setInterval is triggered

daniegloydaniegloy Posts: 35Questions: 12Answers: 5

I have a Editable Datatable that has an ajax setInterval Trigger that updates new data. My problem is that when onClick is triggered on a cell and edit field opens, it exits edit field while typing when ajax interval is triggered. I have managed to prevent this by setting clearInterval(); at onClick and the re-enabling it at focusout. The main problem is that when in the input field state no other data gets updated, and when another cell is selected, it contains "old data". Is there anyway of preventing editing field in cell from exiting when ajax is triggered?

var Tableinterval;
Tableinterval = setInterval( function () {
    table.ajax.reload( null, false ); // user paging is not reset on reload
}, 1000 );
   $('#example').on( 'click', 'tbody td:not(:first-child)', function (e) {
        editor.inline( this );
        clearInterval(Tableinterval);
    } );

Answers

  • daniegloydaniegloy Posts: 35Questions: 12Answers: 5

    $('#example').on( 'focusout', 'tbody td:not(:first-child)',function() {

          Tableinterval = setInterval( function () {
    
              table.ajax.reload( null, false ); // user paging is not reset on reload
          }, 1000 );
    
This discussion has been closed.