Problem with implement Datatables in Moodle platform
Problem with implement Datatables in Moodle platform

Hello there. I tried to implement Datatables in a locally installed moodle platform. Everything worked fine while i had the cachejs option off on the platform, but with I needed to run one last test, turning on that option, the datatables never load.
All i get in the console is the following 'Uncaught TypeError: define(...) is not a function' . I changed the strings in each js file, to point at the local files of the plugin, converted every file to a minified version and everything was running fine until the cachejs option was turned on. Unfortunately I cannot share any link to the tables since its a xampp server and the bookmarklet shows erros in the console too. Any suggestions?
Best Regards,
Yiannis
Answers
if this helps, this is one of the lines that show this error in the console
(function(factory){if(typeof define==='function'&&define.amd){define('local_datatables/buttons.colVis', ['jquery','local_datatables/jquerydataTables','local_datatables/dataTables.buttons'],function($){return factory($,window,document)})}
What is
define
in your application? The bit of code you are looking at there is called a Universal Module Loader (UMD) and it allows DataTables (or whatever else) to work with AMD (RequireJS), CommonJS (Node) or in the browser.It does a check to see if define is a function (
typeof define==='function'
) and then attempts to use it.Could you link to a test page showing the issue you are seeing so we can take a look and help to debug it it please.
Allan