Lightbox links of a repeater in the second state of a multi-state box not working

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!

Thank you so much for your response!

I got that much, and after troubleshooting it for 2 hours, it seems like the only change that the Repeaters are on that second state of the Multi-State Box.

Any additional assistance you think you can help me with? :nerd_face::two_hearts:

Figured it out! I had a major error in this part of the code that was instructing the data from the Repeater instead of the Dataset.


ORIGINAL CODE:

$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)
            });
        });
    });
});

CORRECTED CODE:

$w.onReady(() => {
    $w("#FeaturedCreativeDataset").onReady(() => {
        $w("#FeaturedCreativeRepeater").onItemReady(($item, itemData, index) => {
            $item('#FeaturedCreativeTitle').text = itemData.role;
            $item('#FeaturedCreativeTitle').onClick(() => {
                let item = $item('#FeaturedCreativeDataset').getCurrentItem();
                wixWindow.openLightbox('NEW Cast Lightbox', item)
            });
            $item('#FeaturedCreativeName').text = itemData.name.toUpperCase();
            $item('#FeaturedCreativeName').onClick(() => {
                let item = $item('#FeaturedCreativeDataset').getCurrentItem();
                wixWindow.openLightbox('NEW Cast Lightbox', item)
            });
            $item('#FeaturedCreativeContainer').onClick(() => {
                let item = $item('#FeaturedCreativeDataset').getCurrentItem();
                wixWindow.openLightbox('NEW Cast Lightbox', item)
            });
        });
    });
});


Thanks again for all of your help!

MHx