Cannot read the 'ntr' property undefined

I get the error message "I cannot read the ntr property from undefined" when I execute the mouseover function on the data table when there is no data. It works great when filling out a table. The code is as follows:

$('#example_table tbody td').live('mouseover mouseout', function(event) { if (event.type == 'mouseover') {// do something on mouseover console.log('inside mouseover'); var iPos = oTable.fnGetPosition( this ); // getting error in this line if(iPos!=null){ console.log(iPos); var iCol= iPos [1]; } } }); 

What check should I do so that I don't get this error

thanks

+4
source share
1 answer

You can check if your table is full, and if not return:

 $('#example_table tbody td').live('mouseover mouseout', function(event) { if (event.type == 'mouseover') {// do something on mouseover console.log('inside mouseover'); // check if you have data in your table if (oTable.fnGetData().length <= 0) { // or some similar check return; } var iPos = oTable.fnGetPosition( this ); // getting error in this line if(iPos!=null){ console.log(iPos); var iCol= iPos [1]; } } }); 
+1
source

Source: https://habr.com/ru/post/1497396/


All Articles