I’m trying to get my next and previous buttons working on my dynamic item pages. Following this tutorial: Velo Tutorial: Creating Previous and Next Buttons for a Dynamic Item Page with Code | Help Center | Wix.com
I have successfully entered the code on the items page, but I have issues with the code on the index page.
You can see below that I have already changed the linkField definition to what my fieldNames are in the dynamic item page url’s. Is this correct? My item page url’s end with two fieldNames separated by a “/”.
(Ex. "http…/firstName/lastName).
Also, when I change the #myDataset to the fieldName of my dataset (or even if I change my dataset fieldName to #myDataset), an error pops up for the dynamicPageURLs on the last line (line 12). It’s as if something is different about my own dataset I’m using for the dynamic page that doesn’t let this code work with my dataset. You can see the error in the comments.
Please help.
import {local} from 'wix-storage';
const linkField = "firstName"+"lastName"; // replace this value
$w.onReady(function () {
$w("#myDataset").onReady(() => {
const numberOfItems = $w("#myDataset").getTotalCount();
$w("#myDataset").getItems(0, numberOfItems)
.then( (result) => {
const dynamicPageURLs = result.items.map(item => item[linkField]);
local.setItem('dynamicPageURLs', dynamicPageURLs);
} )
.catch( (err) => {
console.log(err.code, err.message);
} );
} );
} );