I’ve followed closely the instructions for previous/next buttons with a dataset…but there are errors in the code that I paste in from the Wix helper…the errors seem to do with “local” as well as #TEAM – not a valid selector…though that is the dataset name…
lines 11 & 12 : $w(“#TEAM”)
The screen shot is from the index page, and there are similar errors in the item-page code.
Here’s the code without the error message…
Hi Steohen,
In the screenshot i see that you have two $w,onReady. you should only have one.
Is is possible that “TEAM” is the name of the Database collection which connected to the dataset element ?
If so, go to “View Properties” menu of the element and first field shows you the ID name.
The next thing you need to do is to move “import {local} from ‘wix-storage’” to line number one.
If it still doesn’t work. please paste here the link to your site.
Good luck!
Roi
Thanks Roi — I cleaned up the code (sloppy pasting) and figured out the correct name of the dataset. Still doesn’t work and I just can’t figure out what it is…so I’m at a loss… (and it’s probably something really basic)…
The pages are: http://www.mtutd.info/TEAM/defenders/Defender and http://www.mtutd.info/TEAM/Peerapat-Notchaiya (item page)…
The code is:
ITEM PAGE
import {local} from ‘wix-storage’;
import wixLocation from ‘wix-location’;
$w.onReady(function () {
$w(“#previous”).disable();
$w(“#next”).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("#previous").link = dynamicPageURLs[currentPageIndex - 1];
$w("#previous").enable();
}
if (currentPageIndex < dynamicPageURLs.length - 1) {
$w("#next").link = dynamicPageURLs[currentPageIndex + 1];
$w("#next").enable();
}
}
} );
DYNAMIC PAGE
import {local} from “wix-storage”;
const linkField = “title”; // replace this value
$w.onReady(function () {
$w(“#teamdata”).onReady(() => {
const numberOfItems = $w(“#teamdata”).getTotalCount();
$w("#teamdata").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);
} );
} );
} );
Hi,
Can you please write the names of the pages (not url)
Roi
Hello,
Names? – I think you mean as it appears in the list of pages for the site…
TEAM Defenders (Position) and TEAM (name)
thanks.