Problem with implement Datatables in Moodle platform

Problem with implement Datatables in Moodle platform

YiannisLagosYiannisLagos Posts: 2Questions: 1Answers: 0

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

  • YiannisLagosYiannisLagos Posts: 2Questions: 1Answers: 0

    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)})}

  • allanallan Posts: 61,716Questions: 1Answers: 10,108 Site admin

    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

This discussion has been closed.