Search.../

previousPage( )

Moves to the previous page of data.

Description

The previousPage() function returns a Promise that is resolved to an array of the previous page's items when:

  • The current item is saved in the collection (if necessary).
  • The previous page of data is loaded.
  • Any connected elements have been updated with the new data.
  • The current item is updated to the first item in the previous page.

Going to the previous page of data replaces the current items in any connected elements with the new items that correspond to the previous page of data. Elements that have their own settings for how many items are shown at once, such as tables and galleries, are not affected.

Calling previousPage() on a write-only dataset causes an error.

Notes:

  • A dataset needs to load its data before you call its previousPage() function.

    Usually a dataset finishes loading a short time after the page it is on finishes loading. So if you call previousPage() inside the page’s onReady() event handler, the dataset might not be ready yet.

    To call previousPage() 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.

  • When using a read-write dataset and linked input elements, calling any of the following functions will save any changes made in the linked input elements.

Syntax

function previousPage(): Promise<Array<Object>>

previousPage Parameters

This function does not take any parameters.

Returns

Fulfilled - When the previous page of data has been loaded and any connected repeaters have been updated. Rejected - An error message.

Return Type:

Promise<Array<Object>>
Mixed in from:wix-dataset.Dataset

Was this helpful?

Move to the previous page of dataset content

Copy Code
1$w("#myDataset").previousPage()
2 .then( (items) => {
3 let firstItem = items[0];
4 let fieldValue = firstItem.fieldName;
5 } )
6 .catch( (err) => {
7 let errMsg = err.message;
8 let errCode = err.code;
9 } );
Move to the previous page of dataset content when the page loads

Copy Code
1$w.onReady( () => {
2 $w("#myDataset").onReady( () => {
3 $w("#myDataset").previousPage()
4 .then( (items) => {
5 let firstItem = items[0];
6 let fieldValue = firstItem.fieldName;
7 } )
8 .catch( (err) => {
9 let errMsg = err.message;
10 let errCode = err.code;
11 } );
12
13 } );
14
15} );