gpt4 book ai didi

datatables - 无法读取未定义的属性 'ntr'

转载 作者:行者123 更新时间:2023-12-03 07:05:09 24 4
gpt4 key购买 nike

当数据不存在时,当我在数据表上执行鼠标悬停功能时,出现错误“无法读取未定义的属性‘ntr’”。当表格被填充时它工作得很好。代码如下:

$('#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];
}
}
});

我应该做什么检查才能避免出现此错误

谢谢

最佳答案

您可以检查您的表是否已填充,如果没有则返回:

$('#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];
}
}
});

关于datatables - 无法读取未定义的属性 'ntr',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18269459/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com