Toggle menu

helper.utilLoadScripts(scripts, cb)

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

ArgumentTypeDescription
scriptsArray <objects>, requiredAn array of objects with the following properties
scripts[n].srcString, requiredThe URL of the JavaScript file
scripts[n].globalString, requiredThe variable that script will be loaded into
scripts[n].parentObjString, optionalThe name of the scope if not the global scope
cbFunction, optionalA 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

Share this page

Facebook icon Twitter icon email icon

Print

print icon