Connecting different light boxes to gallery images dataset

Hi everyone,

I am just learning the code so real beginner but I am having to advance very quickly.

I am unable to connect gallery items to my lightboxes (I have 28 of them that correspond to the 28 gallery items)

I have tried the following but doesn’t work:

On gallery page
export function gallery1_itemClicked(event, $w) {
$w(‘#dataset1’).setCurrentItemIndex(event.itemIndex)
.then(() => {
wixWindow.openLightbox(‘lightbox name’,
$w(‘#dataset1’).getCurrentItem());

On one light box page to test
import {lightbox} from ‘wix-window’;
$w.onReady(() => {
let item = lightbox.getContext()

I am probably making a very stupid mistake but I don’t know how to code, and it’s a miracle I got this far. Can anyone help me?

Hi Marylin,

Are you using the actual name of the Lightbox in your code?

This is what you have:
wixWindow.openLightbox(‘lightbox name’, $w(’ #dataset1 ').getCurrentItem());

You need something like this:
wixWindow.openLightbox(‘Lightbox1’, $w(’ #dataset1 ').getCurrentItem());

Does this help?

Yisrael

yes, I guess my question is, since I have 28 different light boxes, how do i correspond the items in the gallery to the right lightboxes? I have the gallery connect to a database and so I cannot link each one to each image using the link function in the manage gallery panel.

Do i for example have to write the code below 28times with the different names?

wixWindow.openLightbox(‘Lightbox1’, $w(’ #dataset1 ').getCurrentItem());