my next and previous buttons work in preview and not in live mode.
i checked permissions and dataset mode - all seems ok.
this is a page which displays and edits data so dataset needs to be ‘read and write’
can anyone look at the code below and suggest possible solutions please?
thank you
import {local} from “wix-storage”;
import wixLocation from ‘wix-location’;
const linkField1 = “link-Sales-Notes-jobLog”; // replace this value
const linkField2 = “link-Sales-Fitters-jobDescription”; // replace this value
const jobdesc = “link-Sales-Description-jobDescription”; // replace this value
$w.onReady(function () {
$w(“#dataset1”).onReady(() => {
const numberOfItems = $w(“#dataset1”).getTotalCount();
$w("#dataset1").getItems(0, numberOfItems)
.then( (result) => {
const dynamicPageURLs1 = result.items.map(item => item[linkField1]);
local.setItem('dynamicPageURLs1', dynamicPageURLs1);
const dynamicPageURLs2 = result.items.map(item => item[linkField2]);
local.setItem('dynamicPageURLs2', dynamicPageURLs2);
const dynamicPageURLs8 = result.items.map(item => item[jobdesc]);
local.setItem('dynamicPageURLs8', dynamicPageURLs8);
$w(“#previous1”).disable();
$w(“#next1”).disable();
$w(“#joblog”).disable();
$w(“#fitters”).disable();
$w(“#desc”).disable();
if (local.getItem(‘dynamicPageURLs’)) {
const dynamicPageURLs = local.getItem(‘dynamicPageURLs’).split(‘,’);
const dynamicPageURLs1 = local.getItem(‘dynamicPageURLs1’).split(‘,’);
const dynamicPageURLs2 = local.getItem(‘dynamicPageURLs2’).split(‘,’);
const dynamicPageURLs8 = local.getItem(‘dynamicPageURLs8’).split(‘,’);
const currentPage = ‘/’ + wixLocation.prefix + ‘/’ + wixLocation.path.join(‘/’);
const currentPageIndex = dynamicPageURLs.indexOf(currentPage);
if (currentPageIndex > 0) {
$w("#previous1").link = dynamicPageURLs[currentPageIndex - 1];
$w("#previous1").enable();
$w("#joblog").link = dynamicPageURLs1[currentPageIndex - 0];
$w("#joblog").enable();
$w("#desc").link = dynamicPageURLs8[currentPageIndex - 0];
$w("#desc").enable();
$w("#fitters").link = dynamicPageURLs2[currentPageIndex - 0];
$w("#fitters").enable();
}
if (currentPageIndex < dynamicPageURLs.length - 1) {
$w("#next1").link = dynamicPageURLs[currentPageIndex + 1];
$w("#next1").enable();
$w("#joblog").link = dynamicPageURLs1[currentPageIndex - 0];
$w("#joblog").enable();
$w("#desc").link = dynamicPageURLs8[currentPageIndex - 0];
$w("#desc").enable();
$w("#fitters").link = dynamicPageURLs2[currentPageIndex - 0];
$w("#fitters").enable();
}
}
$w(“#dynamicDataset”).onReady( () => {
//assign the hasDoc variable the value of the field that holds the document in the current item of the dataset.
const q = $w(“#dynamicDataset”).getCurrentItem().quoteDocument;
const q1 = $w(“#dynamicDataset”).getCurrentItem().suppliedDrawings;
const q2 = $w(“#dynamicDataset”).getCurrentItem().associatedDocument1;
const q3 = $w(“#dynamicDataset”).getCurrentItem().materialsList;
const q4 = $w(“#dynamicDataset”).getCurrentItem().workingsOut;
const q5 = $w(“#dynamicDataset”).getCurrentItem().associatedDocument2;
if (q) { //check if hasDoc is true
$w(“#quotedoc”).show(); //enable the button
}
else { //check if haDoc is false
$w(“#quotedoc”).hide(); //change the button label
}
if (q1) { //check if hasDoc is true
$w(“#drawings”).show(); //enable the button
}
else { //check if haDoc is false
$w(“#drawings”).hide(); //change the button label
}
if (q2) { //check if hasDoc is true
$w(“#risk1”).show(); //enable the button
}
else { //check if haDoc is false
$w(“#risk1”).hide(); //change the button label
}
if (q3) { //check if hasDoc is true
$w(“#materials”).show(); //enable the button
}
else { //check if haDoc is false
$w(“#materials”).hide(); //change the button label
}
if (q4) { //check if hasDoc is true
$w(“#working”).show(); //enable the button
}
else { //check if haDoc is false
$w(“#working”).hide(); //change the button label
}
if (q5) { //check if hasDoc is true
$w(“#method”).show(); //enable the button
}
else { //check if haDoc is false
$w(“#method”).hide(); //change the button label
}
}
);
} )
.catch( (err) => {
console.log(err.code, err.message);
} );
} );
} );