In firefox console : Uncaught ReferenceError: DataTable is not defined
and this error is on "new Datable('#xxx', ...
for example :
<script th:inline="javascript">
/* globals DataTable */
const buttTxtPrint = /*[[#{buttontextprint}]]*/ null;
const buttTxtCol = /*[[#{buttontextcol}]]*/ null;
const Personnes = /*[[#{Personnes}]]*/ null;
document.addEventListener('DOMContentLoaded', () => {
new DataTable('#personnes', {
dom: 'Blftip',
scrollX: true,
buttons: [
'csv',
{
extend: 'pdf', exportOptions: {columns: ':visible'},
action: function (e, dt, node, config) {
config.title = Personnes + ' ' + (new Date()).toLocaleDateString();
const inputSearch = this.search();
if (inputSearch.length !== 0) {
config.title += ' <' + inputSearch + '>';
}
$.fn.dataTable.ext.buttons.pdfHtml5.action.call(this, e, dt, node, config);
}
},
{extend: 'print', text: buttTxtPrint},
{extend: 'colvis', text: buttTxtCol}
]
});
});
</script>
Edited by Kevin: Syntax highlighting. Details on how to highlight code using markdown can be found in this guide