添加新脚本时无法重新初始化DataTable

时间:2018-05-19 14:11:19

标签: javascript

我收到了消息

  

DataTables警告:table id = dataTables-table_1 - 无法重新初始化   数据表。

添加此代码后:

<?php
<!-- Internationalisation responsive table -->
<script>
$('#dataTables-table_1').DataTable( {
language: {
    processing:     "Verwerken...",
    search:         "Zoeken:",
    lengthMenu:     "Bekijk _MENU_ records",
    info:           "_START_ tot _END_ van _TOTAL_ records zichtbaar",
    infoEmpty:      "0 van 0 records",
    infoFiltered:   "(totaal _MAX_ records)",
    infoPostFix:    "",
    loadingRecords: "Records worden geladen...",
    zeroRecords:    "Er zijn geen records gevonden",
    emptyTable:     "De tabel is leeg",
    paginate: {
        first:      "Eerste",
        previous:   "Vorige",
        next:       "Volgende",
        last:       "Laaste"
    },
    aria: {
        sortAscending:  ": sorteer oplopend",
        sortDescending: ": sorteer aflopend"
    }
}
} );
</script>
?>

我认为这是因为这已经在剧本中了:

<?php
    <script>
    $(document).ready(function() {
        $('#dataTables-table_1').DataTable({
            responsive: true
        });
    });
    </script>
?>

但是我没有成功地梳理它们,我尝试的所有东西都失去了第一个或第二个JS脚本。请帮帮我。

1 个答案:

答案 0 :(得分:0)

$('#dataTables-table_1').DataTable( {
responsive: true,   //notice the comma
language: {
    processing:     "Verwerken...",
    search:         "Zoeken:",
    lengthMenu:     "Bekijk _MENU_ records",
    info:           "_START_ tot _END_ van _TOTAL_ records zichtbaar",
    infoEmpty:      "0 van 0 records",
    infoFiltered:   "(totaal _MAX_ records)",
    infoPostFix:    "",
    loadingRecords: "Records worden geladen...",
    zeroRecords:    "Er zijn geen records gevonden",
    emptyTable:     "De tabel is leeg",
    paginate: {
        first:      "Eerste",
        previous:   "Vorige",
        next:       "Volgende",
        last:       "Laaste"
    },
    aria: {
        sortAscending:  ": sorteer oplopend",
        sortDescending: ": sorteer aflopend"
    }
}
} );