Hello.
I have my Next and Previou s buttons working with code, but I have noticed that when I create a new database and I try to use the same code to have my buttons going to the next item it will take me to a different database.
There is anyway to keep it from doing that? I just want to see the Next and previous items in the same collection.
I have 4 dynamic pages, the first 2 I created a few months ago are working fine. but the 2 I created recently I am having the problem.
The code I am using I made it following this tutorial: Velo Tutorial: Creating Previous and Next Buttons for a Dynamic Item Page with Code | Help Center | Wix.com
PS. “Anterior” = “Previous” and “Siguiente” = “Next”
Code in Item page:
import {local} from 'wix-storage';
import wixLocation from 'wix-location';
$w.onReady(function () {
$w("#Anterior").disable();
$w("#Siguiente").disable();
if (local.getItem('dynamicPageURLs')) {
const dynamicPageURLs = local.getItem('dynamicPageURLs').split(',');
const currentPage = '/' + wixLocation.prefix + '/' + wixLocation.path.join('/');
const currentPageIndex = dynamicPageURLs.indexOf(currentPage);
if (currentPageIndex > 0) {
$w("#Anterior").link = dynamicPageURLs[currentPageIndex - 1];
$w("#Anterior").enable();
}
if (currentPageIndex < dynamicPageURLs.length - 1) {
$w("#Siguiente").link = dynamicPageURLs[currentPageIndex + 1];
$w("#Siguiente").enable();
}
}
Code in All page:
import {local} from 'wix-storage';
import wixLocation from 'wix-location';
$w.onReady(function () {
$w("#Anterior").disable();
$w("#Siguiente").disable();
if (local.getItem('dynamicPageURLs')) {
const dynamicPageURLs = local.getItem('dynamicPageURLs').split(',');
const currentPage = '/' + wixLocation.prefix + '/' + wixLocation.path.join('/');
const currentPageIndex = dynamicPageURLs.indexOf(currentPage);
if (currentPageIndex > 0) {
$w("#Anterior").link = dynamicPageURLs[currentPageIndex - 1];
$w("#Anterior").enable();
}
if (currentPageIndex < dynamicPageURLs.length - 1) {
$w("#Siguiente").link = dynamicPageURLs[currentPageIndex + 1];
$w("#Siguiente").enable();
}
}
} );