jquery within label

jquery within label

by Cathal O'Riordan -
Number of replies: 1
Picture of Core developers
Hi,

I'm struggling to find a way to make a simple jquery call from within a label on Moodle 3.3 (using Boost theme). Any attempt to reference jquery via '$' or 'jquery' returns undefined. Could someone point me in the right direction?

regards,
Cathal.


Average of ratings: -
In reply to Cathal O'Riordan

Re: jquery within label

by Mark Johnson -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Moodle loads Javascript (including jQuery) using AMD modules via RequireJS.  This means that jQuery isn't available within the global namespace, only when you require it in another AMD module.

The developer wiki has a page introducing how to write Javascript modules in Moodle, including an example using jQuery.

Average of ratings: Useful (1)