Dynamic Lightbox

Hi everyone,

I have a dynamic page that displays patients info and also appointment notes from a different collection through a repeater. Every note has an image field to store a relevant note from that appointment.

I used the link provided in the image settings to open a pop up however I want more info about that image displayed so what I tried to do is to replicate that pop up through a Lightbox, everything works fine with the link however I am not being able to tell the Lightbox that I need to display the information contained in that particular image displayed back in the repeater.

I have tried using the openLightbox function and then send data to it but I am not sure how to accomplish this. I thought that it needs to pass the info on that image container but no sure what object I have to call.

Whenever I open it it brings the same image but not the one related to the specific note being shown by the repeater.

Here is my code so far:

For the dynamic page


For the Lightbox


Thanks for your help

Hey
You can’t add a global onClick to be used with a repeater, then all items will have the same click event and the same data as you have noticed now. You need to code the repeater so the onClick will be per item. Look below.

$w("#myRepeater").onItemReady( ($item, itemData, index) => {
  const repeatedImage = $item("#image12");
  repeatedImage.onClick( (event) => {
    wixWindow.openLightbox("Imagen", itemData._id)
    .then( (data) => {
      let receivedData = data; // Here you get the data from Lightbox
    } );
  } );
} );

Ok Andreas! I understand, still I am missing something to make it work or somehow I have something wrong, here is the code:

on the dynamic page:


And on the Lightbox:

Thanks for your help!

Alex