Search.../

openAppLightbox( )

Opens a lightbox that was added to a site by the Blocks app, during the app installation process and optionally passes it data.

Description

The openAppLightbox() function returns a Promise that resolves to an object with data from the lightbox, when the lightbox is closed. Use it when a widget is installed as a lightbox.
Learn more about app and widget installation settings.

Note that to pass data back to the page that opened the lightbox, you must close the lightbox programmatically using the close() function. If the lightbox is closed by the site visitor clicking the 'X' icon, close button, or lightbox overlay, data will not be passed back the the page that opened the lightbox. Therefore, if you want to make sure data is passed back to the page that opened the lightbox, disable all of the methods mentioned above and create your own method for closing the lightbox programmatically. For example, you can add a button with an onClick event handler that calls the close() function.

Syntax

function openAppLightbox(lightboxId: string, [data: Object]): Promise<Object>

openAppLightbox Parameters

NAME
TYPE
DESCRIPTION
lightboxId
string

The ID of the lightbox, as defined in the installation settings.

data
Optional
Object

The data to pass to the lightbox.

Returns

Fulfilled - The returned data from the lightbox.

Return Type:

Promise<Object>

Was this helpful?

Open a lightbox

Copy Code
1import wixApplication from 'wix-application';
2
3// ...
4
5wixApplication.openLightbox("lightboxId");
Open a lightbox and send it data

Copy Code
1import wixApplication from 'wix-application';
2
3// ...
4
5const dataObj = {title: "Widget Title"};
6wixApplication.openLightbox("lightboxId", dataObj);
Open a lightbox and receive data when it closes

Copy Code
1import wixApplication from 'wix-application';
2
3// ...
4
5wixApplication.openLightbox("lightboxId")
6 .then( (data) => {
7 let receivedData = data; // When the lightbox is closed, it returns this data
8 } );
Open a lightbox, send it data and receive data back when it closes

Copy Code
1import wixApplication from 'wix-application';
2
3// ...
4
5const dataObj = {title: "My Title"};
6wixApplication.openLightbox("ligthboxId", dataObj)
7 .then( (data) => {
8 let receivedData = data; // When the lightbox is closed, it returns this data.
9 } );