Search.../

refresh( )

Refetches the contents of the dataset from the collection.

Description

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

  • The dataset's contents are refetched from the collection, discarding current edits.
  • Any connected page elements have been updated with the values from the collection (read & write mode) or blank values (write-only mode).

Refreshing the dataset sets the current item back to the first item in the dataset regardless of what the current item was before refreshing.

Note:

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

To call refresh() 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 refresh(): Promise<void>

refresh Parameters

This function does not take any parameters.

Returns

Fulfilled - When the refresh is finished. Rejected - An error message.

Return Type:

Promise<void>

Related Content:

Was this helpful?

Refresh the dataset contents

Copy Code
1$w("#myDataset").refresh()
2 .then( () => {
3 console.log("Done refreshing the dataset");
4 } );
Refresh the dataset contents when the page loads

Copy Code
1$w.onReady( () => {
2 $w("#myDataset").onReady( () => {
3 $w("#myDataset").refresh()
4 .then( () => {
5 console.log("Done refreshing the dataset");
6 } );
7
8 } );
9
10} );