Settings script reference
The functions of the script in the settings section and what they receive.
On this page
The first <script> inside <settings> runs in the admin. It can export these functions. Each receives the configuration of the instance and its wrapper in the page, as a jQuery element:
exports.save = function(config, el) {
el.find('.CLASS-box b').text(config.name);
};An error in a function is shown as a warning in the console of the browser, and the configuration is still saved.
API
event
exports.load = function(config, el) {}
Runs when the user opens the settings of an instance.
exports.load = function(config, el) {}| Parameter | Type | Description |
|---|---|---|
config |
Object |
The configuration of the instance. |
el |
jQuery |
The wrapper of the instance. |
Change config to change the values that the form shows. Gallery uses it to open the file picker.
event
exports.save = function(config, el) {}
Runs when the user clicks APPLY.
exports.save = function(config, el) {}| Parameter | Type | Description |
|---|---|---|
config |
Object |
The new configuration, without the hide options. |
el |
jQuery |
The wrapper of the instance. |
Update the HTML of the instance to match the new values. After it, CMS stores config in the instance and adds or removes the hide classes.
exports.save = function(config, el) {
el.find('> div').tclass('CLASS-radius', config.rounded);
};
event
exports.check = function(config, el) {}
Runs for each instance when the editor opens the page.
exports.check = function(config, el) {}| Parameter | Type | Description |
|---|---|---|
config |
Object |
The configuration of the instance. |
el |
jQuery |
The wrapper of the instance. |
It runs again when the list of installed widgets changes. Use it to bring older instances up to date.