const linkField = "link-ourcourses-1-title"; // replace this value
$w.onReady(function () {
$w("#dynamicDataset").onReady(() => {
const numberOfItems = $w("#dynamicDataset").getTotalCount();
$w("#dynamicDataset")
.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("#preBtn").disable();
$w("#nextBtn").disable();
if (local.getItem("dynamicPageURLs")) {
const dynamicPageURLs = local.getItem("dynamicPageURLs").split(",");
const currentPage =
"/" +
wixLocationFrontend.prefix +
"/" +
wixLocationFrontend.path.join("/");
const currentPageIndex = dynamicPageURLs.indexOf(currentPage);
if (currentPageIndex > 0) {
$w("#preBtn").link = dynamicPageURLs[currentPageIndex - 1];
$w("#preBtn").enable();
}
if (currentPageIndex < dynamicPageURLs.length - 1) {
$w("#nextBtn").link = dynamicPageURLs[currentPageIndex + 1];
$w("#nextBtn").enable();
}
}
});
it can change to next item sometimes, but the previous item button is not working. Anyone knows how to fix it?