Datatable not always initialized
Datatable not always initialized
j.castelli
Posts: 10Questions: 4Answers: 0
Hello everyone,
Quite frequently but not all the time I have this error:
Uncaught (in promise) TypeError: $(...).DataTable is not a function at initDatatable
From what I can tell, I think it happens when the datatable is being initialized but the CDN script is not fully loaded yet.
Do you know if there's a way for me to wait for it to be ready before initializing my table?
Thanks!
Answers
Use $(document).ready( function () {...}); like the examples.
Kevin
The thing is I already use it. Here's how the table is initialized in my script:
Here's how my scripts are loaded:
There's indeed a
defer
before the CDN script but if I remove it, then I have an error saying that JQuery is not loaded.To be honest I'm pretty much a noob when it comes to JavaScript, do you think there's a way to overcome this?
This is according to the DOMContentLoaded event docs:
Maybe this SO Thread will help. A better place to research generic Javascript and jQuery questions is on Stack Overflow.
Kevin