Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82612

how do you solve "Uncaught TypeError: $.fn.dataTable.moment is not a function" exception?

$
0
0

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


Viewing all articles
Browse latest Browse all 82612

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>