I'm trying to link repeater containers to lightboxes, but I can't connect that to the database since lightboxes aren't supported (something that would be wonderful to add in the future). I've tried using code with the onclick function for my button in each repeater box, but I can't seem to get it to work. I've tried connecting a string to a text name in the database, but that won't work either. Here's what I have on the box button:
export function button1_click() {
let String1 = ("button1").text;
wixWindow.openLightbox(String1);
}
button 1's text is linked to the database and has the same name as my lightboxes. I want each container in the repeater to link to its own lightbox using this method, but this isn't working as the lightbox seems to need an exact name (ie 'banana') or it won't work. Does anyone have a suggestion? I have a column in my database that has the same name as the lightboxes called "title", so maybe I could use that as well in the lighbox name. Keep in mind I'm not that code savvy (have done an html/css site before but don't understand java well. Thanks so much!
Hi Patrick,
Please make sure the click function contains both event and $w as input parameters in the right order.
Shay
Thanks Shawn,
I got errors from the syntax of the export statement (along with it seeming to not work), but I modified it to this:
export function button1_click(event, $w){
let lightboxName = $w("#button3").label;
wixWindow.openLightbox(lightboxName);
}
And it still won't work. Also I'm getting this error: " $w is not a function ". Any thoughts? I tried putting the "let lightboxName" line in the onReady section of the code as well but that isn't working either. Thanks again!
You are in the right direction. Having the lightbox name in your column is a right approach.
Try the following code. It contains $w as one of the input parameters for the click handler. In addition, it uses the label property of the button to retrieve the lightbox name.
import wixWindow from 'wix-window'; export function button1_click(event, $w){ let lightboxName = $w("#button1").label; wixWindow.openLightbox(lightboxName); }