Running Javascript on Page Load in Moodle App

Re: Running Javascript on Page Load in Moodle App

by Dani Palou -
Number of replies: 1
Picture of Core developers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Hi Sanat,

usually plugins in the app are meant to be used only in their context. E.g. an activity plugin should be run when the activity is open, not all the time. Given your use case, maybe you can create a filter plugin and implement app support, making it implement the handleHtml function. This function should be called everytime the app renders some HTML returned by Moodle, as long as your filter is enabled for that context.

The only way to call PHP functions from JS is with WebService calls, yes.

Cheers,
Dani
In reply to Dani Palou

Re: Running Javascript on Page Load in Moodle App

by Sanat Sharma -
Hi Dani,
I ended up adding a js file for the activity plugin to be called on page load. It was not ideal because I had to change a plugin not owned by me but it works.