Hi, friends!
I currently have a Multi-State Box on my website, currently with two states — and multiple Repeaters inside to pull data from my Content Manager. When the Text or Container contained in those Repeaters is selected, it opens a Lightbox that displays data from the Content Manager that corresponds to the selected item from the Repeater.
And after I finally figured out the coding correctly, this has worked for at least two years.
However, I recently attempted to duplicate it, and I’m finding that whilst the coding to display the text data works, the coding to open the Lightbox is not working — but only on the second state of the Multi-State box; and the prompted reason given, when I hover of the “.getCurrentItem” code is: “Property ‘getCurrentItem’ does not exist on type ‘Repeater’” ( see screenshot below ), which has never been displayed in the past.
The current code that pertains to what I’m looking for is as follows:
import wixData from 'wix-data';
import wixWindow from 'wix-window';
$w.onReady(function () {
wixData.query("FeaturedCreativeDataset")
.find()
.then((results) => {
$w("#FeaturedCreativeRepeater").data = results.items;
})
.catch((err) => {
let errorMsg = err;
});
$w("#FeaturedCreativeRepeater").onItemReady(($w, itemData) => {
console.log(itemData);
$w("#FeaturedCreativeName").text = itemData.name.toUpperCase();
$w("#FeaturedCreativeTitle").text = itemData.role;
$w("#FeaturedCreativeTitle").onClick((event)=>{
wixWindow.openLightbox(itemData.lightbox);
});
});
});
/// CODE SEPARATOR ///
$w.onReady(() => {
$w("#FeaturedCreativeDataset").onReady(() => {
$w("#FeaturedCreativeRepeater").onItemReady(($item, itemData, index) => {
$item('#FeaturedCreativeTitle').text = itemData.role;
$item('#FeaturedCreativeTitle').onClick(() => {
let item = $item('#FeaturedCreativeRepeater').getCurrentItem();
wixWindow.openLightbox('NEW Cast Lightbox', item)
});
$item('#FeaturedCreativeName').text = itemData.name.toUpperCase();
$item('#FeaturedCreativeName').onClick(() => {
let item = $item("#FeaturedCreativeRepeater").getCurrentItem();
wixWindow.openLightbox('NEW Cast Lightbox', item)
});
$item('#FeaturedCreativeContainer').onClick(() => {
let item = $item("#FeaturedCreativeRepeater").getCurrentItem();
wixWindow.openLightbox('NEW Cast Lightbox', item)
});
});
});
});
(I’ve only included code from the first repeater in the second state; once I figure out one, I’m sure I can do the same for the others.)
I believe this should be enough to explain the trouble I’m having.
Can anyone help?
Thanks!