I am having the following error around undefined (reading ‘length’) on Jquery Datatable.
I am generating the table dynamically.
table#myTable.table.is-fullwidth
thead
tr
each column in tableColumns
th
p #{column}
tbody
each row in tableResults
tr
each data in row
td
p #{data}
and call the javascript as such.
script.
$(function() {
$('#myTable').DataTable();
});
I am trying to get some pagination and sorting function into the html table.
Can anyone point me in the right direction?
2
Answers
So I found the issue for this. Basically the DOM is not in the right format, for anyone else who is struggling with this error:
Please check your HTML DOM. Hope this helps someone else who come across this.
Below is my update version of the HTML to be render, i had to provide more indent to the following line: This is written in PUG / Jade.
you need to initialize the DataTable plugin after the document is fully loaded