Search.../

hasPrevious( )

Indicates if there is a previous item.

Description

Returns true if the current item is not the first item in the dataset.

Returns false if the current item is the first item in the dataset.

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

Note:

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

To call hasPrevious() 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 hasPrevious(): boolean

hasPrevious Parameters

This function does not take any parameters.

Returns

true if the current item is not the first item in the dataset.

Return Type:

boolean

Related Content:

Was this helpful?

Get whether the current item is the first item

Code Example

Copy Code
1let hasPrevious = $w("#myDataset").hasPrevious(); // true
Get whether the current item is the first item when the page loads

Code Example

Copy Code
1$w.onReady( () => {
2 $w("#myDataset").onReady( () => {
3 let hasPrevious = $w("#myDataset").hasPrevious(); // true
4
5 } );
6
7} );