Okay, so you are using this tutorial from Nayeli.
https://support.totallycodable.com/en/article/open-a-lightbox-when-clicking-an-item-in-a-repeater-using-a-button?fbclid=IwAR39xj1908HcqDlPj9gJRsntCBc07TrOnM1mLdcNaJyQbs6BvBn8t9rqTTE
So if you follow the tutorial slowly and carefully then you shouldn’t go wrong as it is all clearly laid out with the pictures and text and code fully explained for you.
Lightbox Code.
import { lightbox } from 'wix-window';
import wixData from 'wix-data';
import wixWindow from 'wix-window';
import wixLocation from 'wix-location';
$w.onReady(() => {
let theItem = lightbox.getContext(); //this is the item you took from page
let postID = theItem._id; // this is the field key for the item ID in the database collection
$w("#mushroomDataset").setFilter(wixData.filter()
.eq("_id", postID) //we are now filtering to display only the item that matches this ID
)
.then(() => {
console.log("Dataset is now filtered");
})
.catch((err) => {
console.log(err);
});
});
Page Code
import wixWindow from 'wix-window';
$w.onReady(() => {
$w("#pizzaDataset").onReady(() => {
$w("#buyRepeater").onItemReady(($item, itemData, index) => {
$item('#viewButton').onClick(() => {
let item = $item('#pizzaDataset').getCurrentItem();
wixWindow.openLightbox('Cheese', item)
});
});
});
});
Or you can write it like this.
import wixWindow from 'wix-window';
$w.onReady(() => {
$w("#pizzaDataset").onReady(() => {
$w("#buyRepeater").onItemReady(($item, itemData, index) => {
$item('#viewButton').onClick(() => {
wixWindow.openLightbox('Cheese', itemData)
});
});
});
});
Make sure that you are not missing any ‘;’ from the end of your code lines too as it looks like you have missed a few out in your code from your post.
If you need to do ‘Step 8: Understanding the Page Code to modify it’
In the beginning of the code we are importing the Window API in order to open a lightbox window.
import wixWindow from 'wix-window';
Or ‘Step 9: Understanding the Lightbox Code to modify it’
import { lightbox } from 'wix-window';
import wixData from 'wix-data';
import wixWindow from 'wix-window';
$w.onReady(() => {
let theItem = lightbox.getContext(); //this is the item you took from page
let postID = theItem._id; // this is the field key for the item ID in the database collection
$w("#mushroomDataset").setFilter(wixData.filter()
.eq("_id", postID) //we are now filtering to to
)
.then(() => {
console.log("Dataset is now filtered");
})
.catch((err) => {
console.log(err);
});
});
Then make sure that you read the text below that step carefully and make sure that you understand it all and what the code does.
Finally, also note that Nayeli has done this tutorial with her repeater on a normal page and not a dynamic page.
Step 6: Add a repeater to a regular page and connect it
Add a repeater to a regular page and add elements to the repeater. Style and design as desired.