on-change
Optional
Default: unset
Triggered when: Specific per component. Please see the table below.
Event parameters:
$value
or$object
- The current bound valueoldValue
- The current bound value before the changenewValue
- The current bound value after the change
Component | Triggered when | Return value |
---|---|---|
The device updates the current location. | Location object, e.g. {latitude: -33.9000764, longitude: 18.8476332, altitude: null, horizontal_accuracy: 23.987, vertical_accuracy: null, timestamp: 2022-05-15T11:28:20.794Z} Limitation: Capturing the altitude and/or vertical_accuracy is not supported on several platforms / devices, including Android devices. These devices will return null for these fields. | |
A file is uploaded, or deleted when in display mode. | Attachment id, or null if cleared. E.g. {id: 974abd87-d00f-4255-81ac-16fed6d7085a} | |
A photo is captured or selected from gallery, updated, or deleted when in display mode. | Attachment id, or null if cleared. E.g. {id: 974abd87-d00f-4255-81ac-16fed6d7085a} | |
A signature is captured, updated or deleted when in display mode. | Attachment id, or null if cleared. E.g. {id: 974abd87-d00f-4255-81ac-16fed6d7085a} | |
A date is selected, updated or cleared. | Selected date, or null if cleared. E.g. 2022-05-15 | |
A date and time is selected, updated or cleared. | Selected date and time, or null if cleared. E.g. 2022-05-15T11:28:20.794Z | |
An item is checked or unchecked. | Array containing the selected values. E.g. [email, sms] | |
A new selection is made, or the selection is cleared. | Selected object or an array of selected objects, or null if cleared. E.g. {name: Argentina, population: null} | |
A row is selected. | Selected object, E.g. {name: Argentina, population: null} | |
A barcode is scanned. | String containing the scanned barcode. E.g. "ZQ222-TH678" | |
A new selection is made, or the selection is cleared. | Key of the selected option (string), or null if cleared. E.g. "purple" | |
A new selection is made. | Key of the selected option (string), or null if cleared. E.g. "purple" | |
Text is entered, updated or cleared. | String containing the entered text. E.g. "purple" | |
The toggle state is updated. | true or false |
main.view.xml
<capture-photo bind="my_photo" on-change="$:callEvent($value, oldValue, newValue)" source="any" resolution="small" downloadable="true" />
main.js
function callEvent(currentValue, oldValue, newValue) {
console.log(JSON.stringify(currentValue), JSON.stringify(oldValue), JSON.stringify(newValue));
// Example:
// {"id":"16af8e07-e181-4bdc-a6d7-f3841d0959b7"} {"id":"00cef6fb-0476-40a7-9ec5-f2222d2d7972"} {"id":"16af8e07-e181-4bdc-a6d7-f3841d0959b7"}
}
Last modified 11mo ago