on-change

Optional

Default: unset

Triggered when: Specific per component. Please see the table below.

Event parameters:

  • $value or $object - The current bound value

  • oldValue - The current bound value before the change

  • newValue - The current bound value after the change

Return value: Specific per component (based on field type). Please see the table below.

on-change is an event that calls a JS/TS $:function or navigation. See more details:

Component-specific details

Example:

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 updated