Spanish Total.js
English
Documentation For AI agents
Contents

App reference

The app object of a design and the UIBuilder object of the page, as components and host apps use them.

.md GitHub
On this page

Every design on a page is an app. A component reaches it as instance.app. The page that UI Builder publishes keeps it as window.app, so you can try these calls in the console of the browser.

The page also has one UIBuilder object for all designs.

API

method

app.input(id, data, [callback])

Sends data to an input of the design.
ParameterTypeDescription
id String The id of the input, for example cid6wh0tx52_set.
data Object The data.
callback? Function Receives an error text when the instance or the input does not exist.
Set a Stepper to 2
app.input('cid6wh0tx52_set', 2, function(err) {
	err && console.log(err);
});
method

app.on(name, fn)

Registers a handler of an event of the design.
ParameterTypeDescription
name String The name of the event.
fn Function The handler.

The events are output, change, ready and io.

event

app.on('output', function(meta) {})

An instance has sent an output.
ParameterTypeDescription
meta Object The output.

meta.id is the id of the output in the design, meta.ref its id in the component, meta.data the data, meta.err an error or null, and meta.instance, meta.component and meta.app the objects.

Log every output
app.on('output', function(meta) {
	console.log(meta.id, meta.data);
});
event

app.on('change', function(instance) {})

The state of an instance has changed.
ParameterTypeDescription
instance Object The instance.

Emitted 50 ms after the last change of each instance.

event

app.on('ready', function() {})

All instances are built.
method

app.find(id)

Finds an instance.
ParameterTypeDescription
id String The id, @ and the id, or . and a path.

Returns Object The instance.

property

app.instances

All instances of the design.
property

app.args

The Dynamic arguments of the design.
property

app.query

The query arguments of the address of the page.
property

app.schema

The design as it was built.
property

app.element

The element of the design, a jQuery object.
property

UIBuilder.editor

true in the editor, not set in a published design.
method

UIBuilder.on(name, fn)

Registers a handler for all designs of the page.
ParameterTypeDescription
name String The name of the event.
fn Function The handler.

output receives the outputs of every design, with the same meta as app.on('output'). app runs when a design is built.

method

UIBuilder.build(target, design, [callback])

Builds a published design into an element.
ParameterTypeDescription
target Element Where to put the design.
design Object The published design, as in _render.json, or its JSON text.
callback? Function Receives the app.

Returns Object The app.

The published page calls it with the content of the design. The design needs components and children; a design that is already on the page is removed first.

Build a design
AJAX('GET /designs/demo_render.json', function(design) {
	UIBuilder.build('#design', design, function(app) {
		app.on('output', console.log);
	});
});
Made in Europe