When loading a datatable into a dialog I process initialisation files and scripts using $.getScript(url) and $.globalEval(script).
However, when I add the moment.js code I get the error "Uncaught TypeError: $.fn.dataTable.moment is not a function".
The script is
$.getScript("//cdnjs.cloudflare.com/ajax/libs/moment.js/2.8.4/moment.min.js");
$.getScript("//cdn.datatables.net/plug-ins/1.10.12/sorting/datetime-moment.js");
$.getScript("//cdn.datatables.net/v/bs/dt-1.10.12/b-1.2.2/fc-3.2.2/fh-3.1.2/r-2.1.0/se-1.2.0/datatables.min.js");
$.globalEval(aScript);
aScript is
$.fn.dataTable.moment("DD-MM-YYYY HH:mm");
$("#filelist").DataTable(
{
//various settings
});
If I change the loading order of the files
$.getScript("//cdn.datatables.net/v/bs/dt-1.10.12/b-1.2.2/fc-3.2.2/fh-3.1.2/r-2.1.0/se-1.2.0/datatables.min.js");
$.getScript("//cdnjs.cloudflare.com/ajax/libs/moment.js/2.8.4/moment.min.js");
$.getScript("//cdn.datatables.net/plug-ins/1.10.12/sorting/datetime-moment.js");
$.globalEval(aScript);
I get 2 errors
Uncaught ReferenceError: moment is not defined
and then
Uncaught TypeError: Cannot read property 'moment' of undefined
Any ideas?
Thanks