【发布时间】:2017-05-01 18:55:10
【问题描述】:
首先道歉,因为这可能会重复,因为在继续之前我已经搜索了其他解决方案,但仍然无法弄清楚。我在这段代码中初始化了 Datatables 表:-
$('#get_contacts').on('show.bs.modal', function(e)
{
$('#contacts_table').DataTable({
deferRender: true,
responsive: true,
'bPaginate': false,
'bInfo': false,
ajax: 'send_sms_lib.php?mode=listContacts',
columns: [
{data:'contact_id'},
{data:'contact_name'},
{data:'mobile_numb'},
{data:'contact_id'}
],
'columnDefs': [{
'targets': 3,
'searchable': false,
'orderable': false,
'render': function (data, type, row){
return '<input type="checkbox" id="no" name="no" value="'+data+'">';
}
}]
});
/* *comment temporary since I'm doing my own testing*
$('#group_table').DataTable({
deferRender: true,
responsive: true,
'bPaginate': false,
'bInfo': false,
ajax: 'send_sms_lib.php?mode=listGroup',
columns: [
{data:'group_id'},
{data:'group_name'},
{data:'contact_name'},
{data:'group_id'}
],
'columnDefs': [{
'targets': 3,
'searchable': false,
'orderable': false,
'render': function (data, type, row){
return '<input type="checkbox" id="no" name="no" value="'+data+'">';
}
}]
});
$('#global_contacts_table').DataTable({
deferRender: true,
responsive: true,
'bPaginate': false,
'bInfo': false,
ajax: 'send_sms_lib.php?mode=listGlobalContacts',
columns: [
{data:'contact_id'},
{data:'contact_name'},
{data:'mobile_numb'},
{data:'department'},
{data:'contact_id'}
],
'columnDefs': [{
'targets': 4,
'searchable': false,
'orderable': false,
'render': function (data, type, row){
return '<input type="checkbox" id="no" name="no" value="'+data+'">';
}
}]
});
$('#global_group_table').DataTable({
deferRender: true,
responsive: true,
'bPaginate': false,
'bInfo': false,
ajax: 'send_sms_lib.php?mode=listGlobalGroup',
columns: [
{data:'group_id'},
{data:'group_name'},
{data:'contact_name'},
{data:'department'},
{data:'contact_id'}
],
'columnDefs': [{
'targets': 4,
'searchable': false,
'orderable': false,
'render': function (data, type, row){
return '<input type="checkbox" id="no" name="no" value="'+data+'">';
}
}]
});*/
});
但是当我启动模态时,它会不断弹出错误,如下所示:-
DataTables 警告:表 id=contacts_table - 无法重新初始化 数据表。有关此错误的更多信息,请参阅 http://datatables.net/tn/3
我想销毁或如果可能的话将其称为取消初始化表格,因为该模式由多个菜单选项卡组成,并打算销毁另一个选项卡的表格以从选定的表格中重新初始化表格。这是我打算执行销毁过程的代码:-
$('#get_contacts').on('hidden.bs.modal', function () {
});
【问题讨论】:
标签: jquery datatables bootstrap-modal