Search.../

getPreviousDynamicPage( )

Gets the previous dynamic page URL.

Description

The getPreviousDynamicPage() function can only be called on a dynamic page dataset.

The function returns a Promise that is resolved to the relative URL of the previous dynamic page or null if there is no previous page.

The previous page is determined by the lexicographical order of the dynamic page relative URLs. You can see all of the relative URLs for a dynamic page by viewing the collection connected to the page.

URLs for items that do not match the dataset's filters are not returned.

For example, consider the following situation:

  • You have a collection of employees that contains a boolean field named Active.
  • Your dynamic page datset is filtered to only show employees where Active is true.
  • Some of your dynamic page URLs include:
    • employees/Alice
    • employees/Bob
    • employees/Cathy

If Bob is not an active employee, when you call getPreviousDynamicPage() from Cathy's page, the returned Promise will resolve to "employees/Alice".

Pass the returned URL to the to() function to navigate to the previous dynamic page.

Syntax

function getPreviousDynamicPage(): Promise<string>

getPreviousDynamicPage Parameters

This function does not take any parameters.

Returns

Fulfilled - The URL of the previous dynamic page, or null if there is no previous page.

Return Type:

Promise<string>

Related Content:

Was this helpful?

Get the URL of the previous dynamic page

Code Example

Copy Code
1$w("#myDataset").getPreviousDynamicPage()
2 .then( (prev) => {
3 // do something with previous page URL
4 // URL looks like: "/myCollection/Value"
5 } );
Navigate to the previous dynamic page

Code Example

Copy Code
1import wixLocation from 'wix-location';
2
3$w("#myDataset").getPreviousDynamicPage()
4 .then( (prev) => {
5 if(prev){
6 wixLocation.to(prev);
7 }
8 } );