Lightbox pop up

Hello! Please help me create following tasks in corvid regarding lightbox: 1) When clicking the button on the home page, a lightbox pops up and shows the text from the homepage input element.
2) When the button in the lightbox is clicked, it returns the text from the lightbox input element.

I would really appreciate your help!

https://www.wix.com/corvid/reference/wix-window.html#openLightbox

Thank you so much! My main issue here is that I can’t figure out how to open a lightbox specifically after clicking a specific button. I insert the following code, but the lightbox keeps opening before I click on a button:

import wixWindow from 'wix-window'; 

wixWindow.openLightbox("LightboxName");

Hi @olinse44 ! Did you turn off “automatically display lightbox”?
To do this you need:

  1. Open Lightbox in the Editor

  2. Click “Set Triggers” button

  3. And set “automatically display lightbox on pages” to “No”

Do what Illia has stated above so that it doesn’t trigger on your page and use the code samples provided in the open lightbox reference to learn how to pass data to and from page and lightbox with openlightbox, getcontext, lightboxclose etc.

@givemeawhisky Many thanks for your help, my lightbox was indeed set to be automatically displayed, however, after I disabled this function it stopped appearing on the site at all after clicking on the button.
Just want to specify: does this code need to be added on the page of the Lightbox or no?

@olinse44 To open myLightbox from home page:

  1. I add button1 to home page

  2. Write this code on home page:

import wixWindow from 'wix-window'; 

$w.onReady(() => {
    $w('#button1').onClick(event => {
        const data = {text: 'Text to display on myLightbox'};
        wixWindow.openLightbox('myLightbox', data);
    })
});

And it works well

@olinse44 Thank Illia too please as he is the one giving you the code examples for you to copy and paste, I’m just giving you the links to do it all yourself. :blush:

As for passing data to and from page to lightbox and back again, if you get stuck anywhere then just come back and post your issues here.

Plus, here is a simple tutorial by Vorbly which shows you how to do it as well, however just note that yours will not always look the same as everybody else’s.
https://www.vorbly.com/Vorbly-Code/WIX-CODE-SENDING-DATA-TO-LIGHTBOX

Or you can use the forums search option top right and you will find many pages on the same subject like this one.
https://www.wix.com/corvid/forum/community-discussion/lightbox-passing-data-to-a-page