Question:
[Lightbox will not close via code once opened..]
Product:
[ Velo ,wix editorX.]
What are you trying to achieve:
[ simply close the light box via code once opened not with a user click element input]
What have you already tried:
import wixWindow from ‘wix-window’;
$w.onReady(function () {
// Open the lightbox
wixWindow.openLightbox(‘Promo’);
// Set a timeout to close the lightbox after 3 seconds
setTimeout(function() {
wixWindow.lightbox.close();
}, 3000); // 3000 milliseconds = 3 seconds
});
Additional information:
[ The lightbox displays but will not close via program code. Settings in lightbox on and off seem to have no effect on the outcome. Only closing with button triggers from the lightbox works. I need to do it from the main code. For clarity, I am not trying to close it with any click element from within the code. I assumed that wixWindow.lightbox.close(); would simply close the box if open from the main code. I have tried passing data to to use code and close the lightbox within it directly, but that fails too, giving no error trap. I have tried different browsers Edge by default and Safari and Chrome all do the same in out of editor
Any help would be appreciated .Thank you.
import wixWindow from 'wix-window';
$w.onReady(function () {
// Open the lightbox
setTimeout(function() {
wixWindow.openLightbox('myLightbox');
}, 3000); // 3000 milliseconds = 3 seconds
// Set a timeout to close the lightbox after 3 seconds
setTimeout(function() {
wixWindow.lightbox.close();
}, 6000); // 3000 milliseconds = 3 seconds
});
This code does not close programmatically for me in three different browsers, even though I’ve copied and pasted it exactly. I’ve even renamed ‘Fumble Field’ to ‘myLightbox’ to match the code exactly. Increasing }, 6000); to 6 seconds just delayed the exit but never actually closed it, just as before. Can I just check if you have triggers set to close by a button or user interaction, or any other code in myLightbox itself? Are you running it in the editor ? There isn’t much room for error, as the code should be straightforward. It’s very frustrating. Thanks again.
So you are using Editor-X. I did my testing on ordinary one.
However, now i did the same on Editor-X and found further strange behaviour.
SETUP:
Editor-X
Ordinary Lightbox (nothing else)
No buttons
Working code (inside LIGHTBOX)
import wixWindow from 'wix-window';
$w.onReady(function () {
// Open the lightbox
setTimeout(function() {
wixWindow.openLightbox('myLightbox');
}, 3000); // 3000 milliseconds = 3 seconds
// Set a timeout to close the lightbox after 3 seconds
setTimeout(function() {
wixWindow.lightbox.close();
}, 10000); // 3000 milliseconds = 3 seconds
});
Automatic displaying of the LIGHTBOX → (YES or NO)
a) If you activate the automatic LIGHBOX-POP-UP → The lightbox do show
b) If you deactivate the auto-POP-UP → The lightbox will never show, even controlled by code. It will never pop-up.
However → the CLOSE-Function do still work, if you have the auto-POP-UP setted to → ON.