Check if table td has class error

With data and no doc ready: 1,1,0,true

I… don’t understand why the document ready function would cause that, unless something is later removing the class?

The third number being 1 means that the code saw a cell in the table with the class “dataTables_empty”.
If that changes when the document is ready, something has changed that cell between script location and document load.

Should i give it up lol

I have tried to tackle this from another way. I have changed the code to a .on click event and that works fine. However, if I change it to window load or doc ready, it displays ‘data in row’ even though there is no data. I am confused as to why it works on click event and not on load. Comments would be appreciated as this is driving me nuts. Many thanks

This works

$('#nirqst').on('click', 'tr', function () {
var table = $('#nirqst').DataTable();
 //get the current row
  var currentRow = $(this).closest("tr");
  var col1 = currentRow.find(".dataTables_empty").html(); 
  if((col1)=='No data available in table') { 
    console.log(col1); 
    table.buttons().disable();
    } else {
    console.log('data in row');
    table.buttons().enable();
    }
});

This dosen’t

$( window ).on( "load", function() {
var table = $('#nirqst').DataTable();
 //get the current row
  var currentRow = $(this).closest("tr");
  var col1 = currentRow.find(".dataTables_empty").html(); 
  if((col1)=='No data available in table') { 
    console.log(col1); 
    table.buttons().disable();
    } else {
    console.log('data in row');
    table.buttons().enable();
    }
});