Event System
Events are declared on anyUINode via the events property. Each key is a component event name, and the value is a single EventConfig or an array of them.
EventConfig Fields
Handler Types
script— evaluatestargetas an inline JavaScript expression with access toctxand thekodexa.*bridge.scriptRef— calls a named function from the form’sscriptsorscriptModulesregistry.emit— re-emits the event from the schema root so parent components can listen.store-action— dispatches a Pinia store action (reserved for future use).bus-event— publishes on the application event bus (reserved for future use).
Example: Click and Change Handlers
EventConfig objects. Each handler’s condition is evaluated independently.
QuickJS Runtime
All scripts run in a QuickJS WebAssembly sandbox — isolated from the browser, memory-safe, and protected by a configurable execution timeout.Timeout Configuration
"Script error: interrupted" error.
Defining Scripts
Inline — short expressions placed directly inevents[].target:
scripts dictionary:
scriptRef event handlers or computed bindings on a UINode.
Script Modules
For scripts that need documentation and input/output metadata, usescriptModules. A ScriptModule wraps a function with additional fields:
Document API
Scripts can access the current document through theloadDocument() global, which returns a read-only document proxy. This API mirrors the server-side document wrappers, so scripts work the same way in both environments.
Document Methods
Data Object Methods
Attribute Methods
getValue() returns the first non-null value in this priority order: decimal, boolean, date, dateTime, integer, string.
Write Operations
To mutate the document, obtain a writable proxy through the bridge:- Document:
createDataObject({path, taxonomyRef?}),deleteDataObject(uuid) - Data object:
addAttribute({tag, path, value?}),addChild({path}) - Attribute:
setValue(value),setStringValue(value)
document:read and data:write bridge permissions.
Example: Sum Line Item Amounts
Script Triggers
Script triggers react to changes in data attribute values. They are declared as ascriptTriggers array on the form definition and invoke a named script whenever one of the watched attribute paths changes.
lineItem/amount or lineItem/quantity changes, the recalcTotal script runs after a 300ms debounce window.
Event Triggers
Event triggers react to WASM document events such as attribute changes, object creation, and validation results. They are declared as aneventTriggers array on the form.
deleted:dataObject, deleted:dataAttribute, recalculated:dataAttribute, and validationCleared:dataAttribute. Use these with event triggers to keep form state synchronized with document changes.
Next Steps
Bridge API
Full kodexa.* API reference with permissions and service bridges
Data Binding
Context variables, expressions, and scoped data
