Search...
onBeforeSave( )
Adds an event handler that runs just before a save.
Description
The onBeforeSave()
function allows you to optionally perform actions
right before a save()
operation. When you call save()
, the
callback is run before the save operation. Any validity checks on the
data are run after the callback runs. If the callback function
returns false
, returns a rejected Promise, or throws an error, the
save operation is canceled.
Notes:
- Calling
onBeforeSave()
on a read-only dataset causes an error.onBeforeSave()
runs before any input element validations.
Syntax
function onBeforeSave(handler: BeforeSaveHandler): voidhandler: function BeforeSaveHandler(): Promise<boolean> | boolean
onBeforeSave Parameters
NAME
TYPE
DESCRIPTION
Returns
This function does not return anything.
Return Type:
void
BeforeSaveHandler Parameters
This function does not take any parameters.
Returns
Return Type:
Promise<boolean>
|
booleanWas this helpful?
Register a callback to run before a save and continue with the save
Copy Code
1$w("#myDataset").onBeforeSave( () => {2 console.log("Continuing save");3 return true;4} );
Register a callback to run before a save and cancel the save
Copy Code
1$w("#myDataset").onBeforeSave( () => {2 console.log("Canceling save");3 return false;4} );