Script Examples
Emit Functionality
Emit Example: Download ezUI File
Candidate Component: Download ezUI File
In this example, we illustrate how to use the emit functionality to handle user interactions within a Candidate Component. Users can input data such as first and last names and select a headshot. The system listens for changes in these fields and dynamically updates the component's data, emitting a 'candidateChange' event with the new information.
-
The first step is to create a 'Candidate' component, in order to do this:
- press the
UI Managerbutton - go to the Components section
- press
+and type in the component name - press
Createand thenOpen.
- press the
-
Import the
Candidate Component.ezuifile, then save the created component. - Duplicate the Studio window, open some template.
- Import the
Emit Example.ezuifile. - In the Components section press
Add componentbutton. - Choose the component you have just created, press
Update. - In the Components list find your component (it is in the bottom of the list), drag&drop it to the appropriate section, and delete the excessive one component instead of it.
- Instead of
nameControlin the script, please type theName of your Componentand pressSave.
This ensures that the component reflects the latest user input in real-time. The design ensures smooth user interactions, with updates happening instantly as data changes are detected.
How emit reaches the hosting UI
emit(name, args) fires the handler on<Name> (the first letter of the event name is upper-cased) on the root of the component, and the event then bubbles up through the parent chain. That is why the UI that hosts the component can listen on the component instance itself.
Both listener styles work on the host side:
1 2 3 4 5 | |
The event object carries the properties that were passed to emit (here name and headshot), plus e.sender (the control that emitted the event), e.event (the handler name, onCandidateChange) and e.stopPropagation(), which stops the event from bubbling any further up the parent chain.
Tip
A component also exposes its own child controls to the hosting UI, so nameControl.firstName.value reads the component's firstName text input directly. Only functions and variables have to be declared with export.
Emit Example:
1 2 3 4 5 6 7 8 9 10 11 12 | |
Candidate Component:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | |
Info
getData() is callable from the hosting UI because functions a component script exports are attached to the component element and resolved through the component instance.


