Moodle js code : To execute jquery

in moodle , the way of writting javascript has changed.

you can use followin basic to get the document ready in using jquery

Mustache Tempate

{{#js}}
require(['jquery'], function($){
    $(document).ready(function(){
         alert("hello");
    });
});
{{/js}}

In PHP File

require(['jquery'], function($){
    $(document).ready(function(){
         alert("hello");
    });
});

Leave a Reply

Your email address will not be published. Required fields are marked *