I have a store.
There is main image and gallery images.
Connect the dataset use repeater.
When the button clicked the lightbox open.
I want show product gallery and the product descriptions.
It doesn't work in my code.
◆repeater page code:
import wixData from "wix-data"; import wixWindow from 'wix-window'; var currentItem,ds; export function button6_click(event) { wixWindow.openLightbox('light', $w('#dataset1').getCurrentItem()); }
◆lightbox page code;
import wixWindow from 'wix-window'; $w.onReady(() => { let item = wixWindow.lightbox.getContext();$w('#gallery1') });
please help me.
Hi there 👋🏻 I do something similar on my site. It looks like you aren't setting the elements to display what you want them to. Below is the code I use (of course, change the element IDs to match yours), and the Lightbox code shows you how to connect the elements to your database field keys.
Good luck!
Page code:
import wixWindow from 'wix-window'; $w.onReady(() => { $w("#yourRepeater").onItemReady(($w, itemData, index) => { $w("#yourButton").onClick(() => { const repeaterItem = itemData; wixWindow.openLightbox("Name of Lightbox", repeaterItem); }); }); });
Lightbox code:
import wixWindow from 'wix-window'; $w.onReady(() => { let receivedData = wixWindow.lightbox.getContext(); $w("#yourText").text = receivedData.name; // "name" is the field key $w("#gallery").items = receivedData.images; // "images" is the field key $w("#anotherText").text = receivedData.price; // "price" is the field key // etc, connect all relevant elements });