You are here: Designer > API > Designer Scripts API
 

Designer Scripts API

This page describes the different features available in scripts created inside the Scripts pane. See Write your own scripts.

Features that are only available in Control Scripts are listed in the Control Script API. See Control Script API.

Objects

results The HTML element or set of HTML elements that match the selector specified in the script editor.
record The current record in the main data set.
logger Global object that allows you to log messages.
locale Defines which locale to use.
formatter Global object that allows you to format values.
automation Automation properties
merge Merge properties

Global functions

loadhtml() ​Loads HTML data from a HTML (snippet). The returned HTML can be placed into a variable or into a set of HTML elements.
loadjson()​​ ​Loads json data from an url. This is an simple way to retrieve content from external systems.
​​query() ​Performs a query in the template's contents and creates a new result set containing the HTML elements that match the given CSS selector.

Functions

All these functions can be used with an HTML element or a set of HTML elements, such as the results (the HTML element or set of HTML elements that match the selector specified in the script editor) or the result set returned by a query (see ​​query()).

add()

Adds elements to a set of HTML elements.

​​addClass()

​​Adds the specified class to each element in a set of HTML elements. Has no effect if the class is already present.

after() ​​Inserts content after each element in a set of HTML elements..​
append()

Inserts content at the end of each element in a set of HTML elements.

attr()

Change the given attribute of the element or set of HTML elements with the given value.

before() ​Inserts content before an element or before each element in a set of HTML elements.
css() Gets the value of a style property for the first element in set of HTML elements or sets one or more CSS properties for every element in a set of HTML elements.
​​children()​​ ​Returns the immediate children of an HTML element.
clone() Returns a new result set containing a copy of each element in a set of HTML elements.​

filter()

Returns a subset of the current result set.

find()

Performs a search for a text in the children of each element in a set of HTML elements, and returns a new result set with elements that surround the occurrences.

hasClass() Returns true if the first element in this result set has the specified class.

hide()

Hides the HTML element or set of HTML elements.

html()

​Replaces the inner HTML of the element or of each element in a set of HTML elements with the supplied value, or returns the HTML of the first element if no value is supplied.

is(selector) Returns true if at least one of the elements in a set of HTML elements matches the supplied CSS selector.
parent() Returns the parents of the elements in a set of HTML elements.
prepend() ​Inserts content at the beginning of an HTML element or of each element in a set of HTML elements.
​​remove() ​Removes an HTML element or a set of HTML elements from the document.
removeAttr() Removes the specified attribute from each element in this result set.
removeClass() Removes the specified class from an element or from each element in a set of HTML elements. Has no effect if the class is not present.

replaceWith()

Replaces an HTML element or a set of HTML elements (with a snippet, for example). Returns the result set.

​show() Shows the HTML element or a set of HTML elements.
​​​text()​ Replaces the text content of an HTML element or of each element in a set of HTML elements with the supplied value, or returns the text content of the first element if no value is supplied.​

Examples of iterator functions

Each

A generic iterator function, to iterate over the elements in the result set

For...in​​​ ​Iterates over the enumerable properties of an object, in arbitrary order. For each distinct property, statements can be executed.