I'm trying to integrate the select2 library (a jQuery library that adds search functionality to select boxes) in the admin pages of our Moodle.
When I added the JavaScript file using the requires->js
function (in a php file in my theme), I got the following error:
Error: Mismatched anonymous define() module
I read in the docs that sometimes
RequireJS
could cause this error, and so I added it instead via a script tag in a mustache file in my theme.That solved my problem, but still, I would rather add it the right way. What do I need to do in order for the script to work when added using the
requires->js
function?