Search.../

next( )

Saves the current item and moves to the next item.

Description

The next() function returns a Promise that is resolved to the next item when:

  • The current item is saved in the collection (if necessary).
  • Any connected page elements have been updated with the new current item’s values.

Calling next() on a write-only dataset causes the Promise to reject.

If the dataset is read-write, the current item is saved even if there is no next item.

Note:

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

To call next() 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 next(): Promise<Object>

next Parameters

This function does not take any parameters.

Returns

Fulfilled - The next item in the dataset. Rejected - An error message.

Return Type:

Promise<Object>

Related Content:

Was this helpful?

Move to the next item

Code Example

Copy Code
1$w("#myDataset").next()
2 .then( (item) => {
3 let fieldValue = item.fieldName;
4 } )
5 .catch( (err) => {
6 let errMsg = err;
7 } );
Move to the next item when the page loads

Code Example

Copy Code
1$w.onReady( () => {
2 $w("#myDataset").onReady( () => {
3 $w("#myDataset").next()
4 .then( (item) => {
5 let fieldValue = item.fieldName;
6 } )
7 .catch( (err) => {
8 let errMsg = err;
9 } );
10
11 } );
12
13} );