Hello,
I am having quite a tough time getting things to work as expected when it comes to manually setting/manipulating the data of repeaters. I have tried building a pared down example to show some of the issues I am having. Navigating to -snip- on the published site results in a repeater that doesn’t populate, with this error in the console: “Unhandled promise rejection TypeError: n is undefined”. This page’s repeater will populate correctly in the editor preview. There are two datasets, one with properties and one with associated property photos. The datasets being accessed have general read permissions. On this page I have a button that opens a lightbox. The data used to populate the repeater on the page is passed to the lightbox. The lightbox has a more or less identical setup, from the elements on the page to the code being used; however, in the lightbox, the repeater is housed within a slide on a slideshow.
The lightbox is called as follows:
wixWindow.openLightbox("Bug Lightbox", {property: currentProperty, photos: photos});
Keep in mind, that the repeater on the repeater-bugs page populates correctly in the editor preview, and I’m simply passing the data successfully used to the lightbox.
The lightbox code is as follows:
import wixData from 'wix-data';
import wixWindow from 'wix-window';
const PROPERTIES_SLIDE = 0;
const GALLERY_SLIDE = 1;
const IMAGE_EDIT_SLIDE = 2;
function repeaterOnItemReady($w, item, itemIndex)
{
console.log("Running onItemReady() for item #" + itemIndex);
$w("#itemContainer").background.src = item.image;
$w("#itemContainer").onMouseIn((event, $w) =>
{
$w("#overlayContainer").show();
});
$w("#itemContainer").onMouseOut((event, $w) =>
{
$w("#overlayContainer").hide();
});
$w("#editButton").onClick((event, $w) =>
{
$w("#overlayContainer").hide();
});
$w("#deleteButton").onClick((event, $w) =>
{
$w("#overlayContainer").hide();
});
}
$w.onReady(function ()
{
$w("#editorSlideshow").changeSlide(GALLERY_SLIDE);
let data = wixWindow.lightbox.getContext();
console.log("Attempting to set callback for onItemReady()");
$w("#itemRepeater").onItemReady(repeaterOnItemReady);
console.log("Attempting to set repeater data to empty array");
$w("#itemRepeater").data = [];
console.log("Attempting to set repeater data to photos passed to lightbox");
$w("#itemRepeater").data = data.photos;
});
It’s this last line, seemingly, that is causing a problem. When execution arrives at this point, the following error is observed in the console “TypeError: n is undefined”, and the repeater’s data array is not overwritten.
If we can figure out what is going on with all of this, it might inform some of the oddities I’m experiencing in the main bit of page/code that this is based off of.
Thank you for your time.
Edit: If anyone would care to share how to properly embed code in a forum post that would be appreciated.