Problem with JQuery DataTables in Moodle 3

Problem with JQuery DataTables in Moodle 3

by Ken Currie -
Number of replies: 2

I use the JQuery DataTables library successfully in Moodle 2, but in Moodle 3 I get errors - see below - I think with requiresjs.


Anyone successfully using DataTables?  I am trying to use this library in a module, not theme wide, so that the module would work in any theme.  

Ken Currie


--- Errors --

* Uncaught TypeError: $(...).DataTable is not a function

    at HTMLDocument.<anonymous> (view.php?id=35:116)

    at i (jquery-1.12.1.min.js:2)

    at Object.fireWith [as resolveWith] (jquery-1.12.1.min.js:2)

    at Function.ready (jquery-1.12.1.min.js:2)

    at HTMLDocument.K (jquery-1.12.1.min.js:2)


* Uncaught Error: Mismatched anonymous define() module: function (E){return h(E,window,document)}

http://requirejs.org/docs/errors.html#mismatch

    at B (require.min.js:12)

    at J (require.min.js:27)

    at require.min.js:27

Average of ratings: -
In reply to Ken Currie

Re: Problem with JQuery DataTables in Moodle 3

by kien Vu -
You can try this 


It fixed the similar issue for me.

Cheers,

Kien

In reply to kien Vu

Re: Problem with JQuery DataTables in Moodle 3

by Raymond Mlambo -

Hi Kien,

You just might solve all my problems with jquery ui if your answer to my question is yes.

If I call this line which you provided above, will i instantly get access to the jquery ui datatables functionality? Without having to write/ build any AMD modules as prescribed in the moodle docs?

$PAGE->requires->js(new moodle_url('https://cdn.datatables.net/1.10.15/js/jquery.dataTables.min.js'),true);