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");
    });
});

developerCK

E-learning Solution Architect | Technical Enthusiastic | LAMP Stack Developer | AWS Cloud Solution Architect (2x) | OCI (5X)

You may also like...

Leave a Reply

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