JC_API: JavaScript API for SiteArchitect
JavaScript object: top.JC_API
Access API documentation: JavaClientApi
SiteArchitect provides a JavaScript API which includes functionality to trigger reloads of the preview in an integrated browser as well as execution of FirstSpirit scripts in the Templates store and of executable classes supplied by FirstSpirit Modules.
This API is accessible via the JavaScript object top.JC_API and may be used in JavaScript processed inside an HTML document in an integrated browser preview.
Reloading the Preview
void reload() causes a reload of the current preview URL of the integrated browser in which the JavaScript code is running.
Executing Scripts and Executables
Object execute(String executable) causes execution of the referenced FirstSpirit script (stored in the Templates store) or a class, supplied by a FirstSpirit Module, which implements the FirstSpirit Access API interface Executable.
Object execute(String executable, Map parameters, String callback) causes execution of the referenced script or executable class (as described above), supplying the parameters contained in the map object to that script or executable. The given script or executable is executed asynchronously, so any return value is passed to a JavaScript callback function.
Parameter Reference
- String executable references a FirstSpirit script or an executable class supplied by a FirstSpirit Module.
- Use the value format script:<SCRIPT_UID> to reference a script in the FirstSpirit Templates store by its UID.
- Use the value format class:<FULLY_QUALIFIED_CLASS_NAME> to reference a class which implements the Access API interface Executable.
- Map parameters supplies a map in JSON format with one or more key-value pairs, e.g. {"param1":"value1", "param2":"value2"}. These parameters will be supplied to the script or the executable.
- String callback supplies the name of a JavaScript function or a complete JavaScript function object which accepts one parameter to process the script's or executable's return value in the preview document.