Only if I do not switch to the second lightbox, and close at the first lightbox, then I can open the second lightbox again.
I use this way to collect information at different lightboxes.
Actually it worked before, just that it didn’t work one day suddenly, so I suspect there is a bug.
Please help to see if there is any bug at the lightbox, thank you.
I see the problem.
Maybe it’s a bug, you can report it.
But meanwhile you can try closing the first lightbox by code together with opening the second one.
This is the error you get when you try to reopen the 2nd lightbox:
I think that in order to get this to work you will have to add the code to open the second lightbox to the page code where you opened the lightbox originally. Technically once the lightbox is closed the page code for that lightbox is terminated. Meaning it would not see the line to open the second lightbox.
Since you can not open a lightbox while another one is already opened we can also not call that line of code before closing the existing lightbox. Therefore we have to have an intermediary to process the redirect successfully.
One thing you could try is passing a data object into the close function that contains the name of the second lightbox you would like to open. That would look something like this:
Lightbox page:
export function close() {
let newLightBox = "lightBox2"
wixWindow.lightbox.close({data: newLightbox});
}
I have not tried this bit it should work based on the following recourses:
openLightbox - Velo API Reference - Wix.com
close - Velo API Reference - Wix.com
Also something cool is that the lightbox will not pass the data object back to the page if it is closed with the “X” or by clicking on the background. This makes the close function especially easy to bind to a button. You could also (in theory) have multiple lightboxes with the ability to go back or foreword to a previous lightbox.
@jonatandor35 I have reported it to WIX customer care, and after review she said will report it to the team to check the bug. Will see how the reply goes. Thank you.
This code solution does work – just tried it, as I have been experiencing the same error. However, I have linked light boxes with data successfully in the past without having to resort to this method. So something changed under the covers in Wix since the last time I did this (July, 2021).
We also encountered this BUG, and still not fix yet, which making our website malfunction as we rely on this feature. Wix change something under the covers and not informing us.
And the most annoying thing is, the openLightbox function cannot handle opened lightbox, and Wix don’t have closeLightbox function as well to force some opened lightbox to close.
This is just simple UI control features, and should be easy for Wix engineer to implement.
Thanks Amotor, our case cannot use your method, as we need to pass data to first lightbox, and then pass data from first lightbox to second lightbox. So we cannot use close lightbox function inside first lightbox.
Even though WIX can close first lightbox properly and open second lightbox, but the BUG will be triggered at the moment when user close the second lightbox. And then the second lightbox never close and no way to force it to close, user need to reload the whole page from browser.
Trying to open one lightbox directly from another open lightbox is not possible and will give you the errors that you are seeing. The parent page HAS TO BE the intermediary to handle opening and closing of multiple lightboxes and passing data between them. There is no other way to accomplish this task
We just rewrite our code and it works smoothly, thanks lot!
I think your suggested way is the most proper way for multiple lightboxes switching. The method we used before was bypassing WIX system hierarchy, so actually we were lucky to use our old method and kept worked for few years XD
@davebogan98 After I reported it, WIX still hasn’t fixed it (1st April 2022). Maybe you could report as well. See if more people reporting will work.
The solution above is correct, and able to pass data between (or use memory to save data). But if I want to switch forward and also backward between lightboxes, it becomes complicated.
At the end I use the “Multi-state box” element instead of lightboxes (put a Multi-state box in a lightbox), as it can switch between “states” easier, and save data in the same page. Plus it is faster to load between “states” than between lightboxes.
So the solution I use is a mix of above code if I really need to switch between lightboxes, and “Multi-state box” for continuous lightboxes.
“Multi-state box” is in EditorX, and I believe “slideshows” is for WIX editor.
I wish WIX will fix the bug so it can go back to the way it was, which is easier to code