Script Examples
Communication between the Show UI and the Template UI
Show UI:
Download ezUI File
Template UI:
Download ezUI File
In this example, we demonstrate the communication process between the Show UI and the Template UI to dynamically update the graphical user interface based on user input.
By storing the user's selection in session storage and listening for changes, the Template UI can promptly reflect the user's choices, providing a responsive and interactive user experience.
Info
sessionStorage in UI Builder is a shared, per-client store: a value written by one user interface is broadcast to every other user interface open in the same Studio window. sessionStorage.on(key, callback) receives { key, value } whenever that key changes, no matter which UI changed it. once(key, callback) and off(key, callback) are available as well.
Warning
Storage values must be strings. setItem silently ignores a non-string value, so wrap anything else in String(...) or JSON.stringify(...) before storing it.
Show ezUI:
1 2 3 4 5 | |
Template ezUI:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | |
Tip
Assigning undefined to a style property clears it, which is what restores the default border colour on the buttons that are not highlighted.
See Storage for the other storage scopes and for values that have to survive longer than the current Studio window.
