Overview
The Joyfill SDK provides comprehensive event handling to track all user interactions and document changes. This guide covers how to listen for and handle various types of form changes.Basic Change Handling
onChange Event
The primary way to listen for form changes is through theonChange callback:
Changelog Structure
Each changelog contains detailed information about the change:Event Types
Field Events
Field Updates
Field Creation
Field Deletion
Page Events
Page Creation
Page Updates
Table Row Events
Row Creation
Row Updates
🎯 Advanced Event Handling Guide
Overview
The Joyfill SDK provides comprehensive event handling to track all user interactions and document changes. This guide covers all available event handlers and their corresponding changelog structures for advanced form management.Event Handler Types
The Joyfill SDK provides the following public event handlers:onFocus- Field focus eventsonBlur- Field blur eventsonChange- Document changes (field, fieldposition, page, style changes)onCaptureAsync- Barcode capture eventsonUploadAsync- File upload events (images)onFileUploadAsync- File upload eventsonFileClick- File click eventsonFileDelete- File deletion events
Event Parameters
All event handlers receive structured parameters with the following common properties:| Name | Type | Description |
|---|---|---|
| v | Number | Changelog version number |
| sdk | String | Specifies the name of the SDK that generated the changelog object |
| target | String | Specifies the target change that was made |
| _id | String | Specifies the target document _id for the change |
| identifier | String | Specifies the target document identifier for the change |
| fileId | String | Specifies the target file _id for the change |
| pageId | String | Specifies the target page _id for the change |
| fieldId | String | Specifies the target field _id for the change |
| fieldIdentifier | String | Specifies the target field identifier for the change |
| fieldPositionId | String | Specifies the target field position _id for the change |
| change | Object | Object containing the properties and values that should be applied for the change |
| createdOn | Number | Millisecond timestamp of the change event |
Focus and Blur Events
onFocus
Triggered when a field receives focus.
Event Parameters:
params(Object): Focus context informationevent(Event): The DOM focus event (callevent.blur()to blur the currently focused field)
onBlur
Triggered when a field loses focus.
Event Parameters:
params(Object): Blur context informationevent(Event): The DOM blur event
Change Events
onChange
The primary event handler for all document changes.
Triggered for:
- Field changes - Field value or property updates
- Field position changes - Field position, size, or display changes
- Page changes - Page creation, updates, or deletion
- Style changes - Theme and styling modifications
changelogs(Array): Array of changelog objects describing the changesupdatedDoc(Object): The updated document state
Capture Events
onCaptureAsync - Barcode Capture
Triggered when barcode capture is initiated (e.g., table barcode cell, barcode field).
Function Signature:
- Called without any parameters when user clicks the barcode capture button
- Expected to return a Promise that resolves to the captured barcode value (string)
- The returned value will be automatically populated into the barcode field
Upload Events
onUploadAsync
Triggered when file upload is initiated for image fields, both in normal fields and table field cells.
Note: This function will be called only when onFileUploadAsync is not passed into JoyDoc. If onFileUploadAsync is present, it will be triggered instead of this.
Function Signature:
params(Object): Upload context informationfiles(Array<File>): Array of File objects selected by the user
onFileUploadAsync
- onFileUploadAsync is an async callback in
fieldSettings.fieldthat handles file uploads for specific fields. It overrides the global onUploadAsync when provided.
params(Object): Upload context informationfiles(Array<File>): Array of File objects selected by the user
File Interaction Events
onFileClick
Triggered when a file is clicked or selected in an image field.
Function Signature:
params(Object): Context information about the file clickurlObject(Object): Information about the clicked file
onFileDelete
Triggered when a file is deleted from an image field.
Function Signature:
params(Object): Context information about the file deletionurlObject(Object): Information about the file being deleted