How to close Lightbox from outside?

Is there any way to close a lightbox from a page code?

For example:

// Open a lightbox
..
// Execute some functions
// Then close the lightbox 

Some function that return a promise might take a while to return their promise, in the meanwhile, I want to show a lightbox to prevent users from changing anything on the page that might affect the final result of the promise chain.

wixWindow.lightbox.close() // only works from inside the lightbox

Is there a solution or a way around? Using a regular box doesn’t look great since there’s a lot of content that are changing dynamically, so I can’t really set a fixed height for the box, sometimes the box will look too small, and sometimes will look too large.

Help is appreciated.

Is there an answer for that?

Ive made a workaround (not a charmy):

Create a new lightbox (lets call it “Fake”) without content with background color 1%;
Use this code in ‘onReady’ scope to close itself:

$w.onReady(function () {
    wixWindow.lightbox.close()
});

So, when you need to close your real lightbox, open Fake lightbox then the lightbox gonna close :wink:

// Open a lightbox
..
// Execute some functions
// Open the Fake lightbox, like:
wixWindow.openLightbox("Fake")
// Continue your code