A function used to dynamically load multiple third party JavaScript libraries.
Scripts are only loaded if they don't already exist, whether in the runtime, the site frameworks (when loading scripts client-side) or loaded by another field.
Executed
Client-side and server-side.
Arguments
Argument | Type | Description |
---|---|---|
scripts | Array <objects>, required | An array of objects with the following properties |
scripts[n].src | String, required | The URL of the JavaScript file |
scripts[n].global | String, required | The variable that script will be loaded into |
scripts[n].parentObj | String, optional | The name of the scope if not the global scope |
cb | Function, optional | A function to execute after loading the scripts |
Example
Included in a page init function this would make an additional JavaScript library available to your form.
function(helper, fieldName, value, valid, eventName) {
helper.utilLoadScripts([{
src: "https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.3.14/proj4.js",
global: "proj4"
}], function() {
proj4.doSomeStuff;
helper.setVariable("scriptLoaded", "OK");
});
}
Last modified on March 06, 2020