Hello There,
So I’ve been messing around with my upcoming website and I need a specific page to show multiple galleries. I’ve looked around and found the Dynamic Pages to suit my needs.
The issue is I cannot seem to figure the buttons to iterate between pages correctly…
Whenever I click the “RightButton” (Next Button) it will iterate between the first two pages, and the back button is never enabled.
The thing is, it does sounds legit action since I don’t actually change the index, rather just link every-time to index+1 (which will always be 0+1)… what’s the correct way to do that?
Heres the code:
"
import {local} from ‘wix-storage’;
import wixLocation from ‘wix-location’;
const linkField = “link-Installations-title”;
$w.onReady( function ()
{
$w(“#Install”).onReady(() => {
const numberOfItems = $w(“#Install”).getTotalCount();
$w(“#Install”).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);
} );
} );
} );
$w.onReady( function ()
{
$w(‘#LeftButton’).disable();
$w(“#RightButton”).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(“#LeftButton”).link = (dynamicPageURLs[currentPageIndex - 1]);
$w(“#LeftButton”).enable();
}
if (currentPageIndex < dynamicPageURLs.length - 1)
{
$w(“#RightButton”).link = (dynamicPageURLs[currentPageIndex + 1]);
$w(“#RightButton”).enable();
}
}
} );
"
Would love some help!
Thanks!