General developer forum

jQuery & jQuery UI in Moodle 3.4

 
Picture of Justin Hunt
Re: jQuery & jQuery UI in Moodle 3.4
Particularly helpful MoodlersPlugin developers

If the JQuery plugins are AMD compatible, you should just be able to include them as dependencies normally. 

See this post regarding loading JQuery UI (which arejquery plugins)

https://moodle.org/mod/forum/discuss.php?d=327189


If they are not, then life is a bit harder. I use $.getScript from within the AMD module itself to load the plugin. You probably also need some plumbing to make sure we only load the library once.  Here is an example from the Fancybox generico template...

 $.getScript('https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.1.20/jquery.fancybox.min.js', function(){
     //do something with the newly loaded plugin
  });
 
Average of ratings: -