Search.../

revert( )

Reverts the current item to its saved value.

Description

The revert() function returns a Promise that is resolved when:

  • The current item is reverted to its saved state in the collection.
  • Any connected page elements have been updated with the current item’s old values (read & write mode) or blank values (write-only mode).

Calling revert() on a read-only dataset causes the Promise to reject.

Note:

A dataset needs to load its data before you call its revert() function. Usually a dataset finishes loading a short time after the page it is on finishes loading. So if you call revert() inside the page’s onReady() event handler, the dataset might not be ready yet.

To call revert() as soon as possible after a page loads, use the dataset's onReady() function inside the page’s onReady() event handler to ensure that both the page and the dataset have finished loading.

Syntax

function revert(): Promise<void>

revert Parameters

This function does not take any parameters.

Returns

Fulfilled - When the item has been reverted to its saved state. Rejected - An error message.

Return Type:

Promise<void>

Related Content:

Was this helpful?

Revert the current item

Copy Code
1$w("#myDataset").revert()
2 .then( () => {
3 console.log("Done reverting the item");
4 } )
5 .catch( (err) => {
6 let errMsg = err;
7 } );
Revert the current item when the page loads

Copy Code
1$w.onReady( () => {
2 $w("#myDataset").onReady( () => {
3 $w("#myDataset").revert()
4 .then( () => {
5 console.log("Done reverting the item");
6 } )
7 .catch( (err) => {
8 let errMsg = err;
9 } );
10
11 } );
12
13} );