Events
Jedison provides several events that let you track changes and user interactions in your forms. These events are useful because they allow you to:
- React immediately when data changes (like saving to a database)
- Synchronize form state with other parts of your application
change
Triggered when the entire instance changes (whole JSON value/instance/editor).
Callback receives (initiator) where initiator is either:
"api"- Change from method calls likesetValue()"user"- Change from direct user interaction
jedison.on('change', (initiator) => {})
instance-change
Triggered when a specific part of the instance changes.
Callback receives (instance, initiator):
instance: The changed instanceinitiator: Same aschangeevent
jedison.on('instance-change', (instance, initiator) => {})
item-add
Triggered when adding items to arrays.
Callback receives (initiator, newInstance):
newInstance: The newly added array item instance
jedison.editor.on('item-add', (initiator, newInstance) => {})
item-delete
Triggered when removing items from arrays.
Callback receives (initiator).
jedison.editor.on('item-delete', (initiator) => {})
item-move
Triggered when reordering array items.
Callback receives (initiator).
jedison.editor.on('item-move', (initiator) => {})
Removing listeners: off()
Stops a callback from being called for a given event.
jedison.off(name, callback)- Removes that specific callbackjedison.off(name)- Removes every listener registered for that event
const onChange = (initiator) => {}
jedison.on('change', onChange)
jedison.off('change', onChange)
jedison.off('change')