The lightbox is not opening. please help me! Anyone please.

hello,
I tried writing a simple code to open a lightbox but it is simply not working. I directly copied the code from Wix lightbox API collection to avoid mistakes but it is simply not working i cannot understand this. please help me.

here are the codes i tried;

import wixWindow from ‘wix-window’;

export function button3_click(event) {
wixWindow.openLightbox(“LBC”);
}

and:

  1. export function button3_click(event) {

  2. //Add your code for this event here:

  3. let scope = $w.at(event.context);

  4. let currentPost = scope(’ #dataset1 ').getCurrentItem();

  5. wixWindow.openLightbox(“LBcomment”, currentPost);

  6. }
    I have also tried this code without success

  7. export function repeater1_itemReady($item, itemData, index) {

  8. //Add your code for this event here:

  9. $item(" #button3 ").onClick(()=> {

  10. wixWindow.openLightbox(“LBcomment”);

  11. })
    thank you in advance

Did you add the onClick event handler through the button properties panel in the editor?
https://support.wix.com/en/article/corvid-reacting-to-user-actions-using-events

Also, don’t forget to add your pages onReady function after your imports.
https://www.wix.com/corvid/reference/$w.html#onReady

Finally, make sure that the actual lightbox settings are setup correctly for the lightbox triggers.
https://support.wix.com/en/article/about-lightboxes

Thank you for the reply @givemeawhisky I have done all of the above but it is not opening still. that was why i posted in here because it is so confusing.

please help me out

Please post the editor URL of your site. Only authorized Wix personnel can get access to your site in the editor. Please include the name of the page involved.

1 Like

thank you for your response @yisrael-wix . the site is a little messy as it is under construction
I want to connect the comment button on the repeater to the comment (sidebar) lightbox and send it data but it is not even opening the lightbox. the page name is the main page (search). here is the link
https://editor.wix.com/html/editor/web/renderer/edit/c04be7a4-7702-42e7-b5c5-eb45db15c154?metaSiteId=5140d697-5b57-4748-ad9d-cab5cf80ed76&editorSessionId=7cf8e8df-cde2-4dba-b534-00b1e7b80a6c&referralInfo=my-account

You have no code in your button3_click() event handler to open a lightbox. You will need to call the openLightbox() function. See the lighbox API for more information.

@yisrael-wix
Thank you for checking it out. however, I don’t understand. I have already added the code after calling the on-click event handler of the button as seen in the picture below. can you please explain further if you can?

Thank you.

With the repeater you can’t just use the normal code as on the page, you will have to look at using code for scope of the repeater, maybe like $item for the button as shown here for Repeater in the Wix API Reference.
https://www.wix.com/corvid/reference/$w.Repeater.html

If you are after more info on it, then look at Yisrael’s example page here about using inputs in a repeater, which you can open up in your own Wix Editor to see the page all laid out with all the code applied on the page too.
https://www.wix.com/corvid/forum/corvid-tips-and-updates/example-input-repeaters

If you want to pass data from a page to a lightbox, then you want to be looking at using lightbox code like get context.
https://www.wix.com/corvid/reference/wix-window.lightbox.html
https://www.wix.com/corvid/reference/wix-window.lightbox.html#getContext
How do I pass data between a page and a lightbox?
When you open a lightbox using the openLightbox() function, you can pass an object containing data to be used in the lightbox. In the lightbox’s code, you call the getContext() function to retrieve the data sent by the openLightbox() function.
When you close the lightbox using the close() function, you can pass an object containing data to be used by the page that opened the lightbox. This data is retrieved from the resolution of the Promise returned by the openLightbox() function.

Make sure that you read the info about getContext as you need to make sure that your lightbox settings in the editor are correctly setup too, otherwise it will not work.

1 Like

@Yisrael (Wix)
Thank you for the directions. they are helping me successget closer to a solution. I have managed to write some code for the repeater to open the lightbox. I get only for now as i want to get it right gradually but it is still not opening the Lightbox. below is the code: kindly check it out

export function button3_click(event) {
//Add your code for this event here:
let scope = $w.at(event.context);
let currentPost = scope(‘#dataset1’).getCurrentItem();
wixWindow.openLightbox(“LBcomment”, currentPost);
}

i have also tried this code without success

export function repeater1_itemReady($item, itemData, index) {
//Add your code for this event here:
$item(“#button3”).onClick(()=> {
wixWindow.openLightbox(“LBcomment”);
});
}
thank you in advance