-
Bug
-
Resolution: Fixed
-
Minor
-
None
-
3.9.0
-
-
MOODLE_39_STABLE
-
Moodle App 3.9.3
Documentation https://docs.moodle.org/dev/Mobile_support_for_plugins#Initialization says you can do this in a plugin init function:
(begin paste)
Finally, if you return an object in this init Javascript code, all the properties of that object will be passed to all the Javascript code of that handler so you can use them when the code is run. For example, if your init Javascript code does something like this:
var result = {
|
MyAddonClass: new MyAddonClass()
|
};
|
result;
|
Then, for the rest of Javascript code of your handler (e.g. for the “main” method) you can use this variable like this:
this.MyAddonClass
|
(end paste)
This does not appear to actually work. Here is examples from my code, running in a main menu handler.
End of init.js:
console.log('---Ran TEST code--');
|
var result = {
|
MyAddonClass: "TESTING"
|
};
|
result;
|
Start of page .js:
console.log('Test input values');
|
console.log(this.MyAddonClass);
|
console.log('DONE');
|
Excerpts from console:
Running against app tag v3.9.0:
---Ran TEST code--
|
[...and when the page loads...]
Test input values
|
undefined
|
DONE
|