Hello,
I am getting an error in my live site that says $w(…).onReady is not a function, and references my dataset’s onReady. The code works as expected in preview mode, but breaks when I publish and go live. I have checked the database permissions already, and set the dataset to both ‘read-only’ and’read-write’, to no avail. I have also checked that the databases are all synced to live. I am not sure why my code would work exactly as expected in preview mode and not in live. Here is the page code for the lightbox where this error occurs.
import wixWindow from 'wix-window';
import wixData from 'wix-data';
$w.onReady(function () {
$w('#repeater1').hide();
$w("#dataset1").onReady(() => {
let clientEmail = wixWindow.lightbox.getContext();
let cartDisplay = [];
wixData.query('CodePacks')
.hasAll('packName', clientEmail)
.find()
.then((results) => {
let cartCodes = results.items[0].incCodes;
console.log(cartCodes);
let total = $w('#dataset1').getTotalCount()
$w('#dataset1').getItems(0, total)
.then((codeResults) => {
let codeIds = codeResults.items;
for (let i = 0; i < cartCodes.length; i++) {
for (let j = 0; j < total; j++) {
if (codeIds[j]._id === cartCodes[i]) {
cartDisplay.push(codeIds[j]);
}
}
//$w('#dataset1').setFilter(wixData.filter().hasAll('_id', cartCodes[i]));
//cartDisplay.push($w('#dataset1').getCurrentItem());
}
console.log(cartDisplay);
$w('#repeater1').data = cartDisplay;
updateRepeater();
});
});
});
});
export function updateRepeater() {
$w("#repeater1").show();
$w("#repeater1").forEachItem(($item, itemData, index) => {
$item("#text17").text = itemData.codeName;
});
}
Any help would be greatly appreciated!
Thanks,
Stephen