【发布时间】:2017-02-06 17:01:10
【问题描述】:
我的项目在 Internet Explorer 10 和 DataTable.destroy() 之间遇到了兼容性问题。我有很多 DataTable,当我更改或添加数据时,我使用 Ajax 和 $("#" + this.id).DataTable.destroy() 来重建表。
以下是用于初始化 DataTables 的代码:
$('.tableReleves').each(function( index ) {
if(this.childElementCount>1) {
$("#" + this.id).DataTable({
"paging": true,
"info": false,
"searching": false,
"retrieve": true,
"language": {
"paginate": {
"previous": "«",
"next": "»",
}
},
"columnDefs": [
{"type": "currency", "targets": this.id.contains('apres') ? [-2, -1] : -1}
]
});
}
});
toDestroy = true;
更新或添加新数据后,我用它来更新我的数据表
if(toDestroy) {
$('.tableReleves').each(function( index ) {
if(this.childElementCount>1) {
$("#" + this.id).DataTable.destroy()
}
})
}
(toDestroy变量用于避免在页面加载过程中调用该部分)
这在 chrome 或 Firefox 上运行良好,但在 IE 上显示错误。
无法获取属性“样式”的值:对象为空或 未定义
我尝试了一些方法,例如 draw()、clear(),但在三个 Web 浏览器上都没有任何效果。
谢谢。
【问题讨论】:
标签: jquery ajax internet-explorer datatables