Hello Wix Teamsters!
I’ve looked everywhere for a solution but no dice! I have an onclick function on a button in the header to open a light box. Is it possible to hide an element inside the lightbox when it opens onclick. I’ve looked everywhere and tried code but failed.
Is there a way to achieve this?
Any suggestions is much appreciated… Thank You All!
Yes this is surely possible in different ways.
- Using a public JS.js-File for example.
- Also possible by using the wix-storage.
- Using a DB.
- Or using the own send-option of the lightbox itself.
import wixWindow from 'wix-window';
wixWindow.openLightbox("LightboxName", dataObj);
Thank you Velo-Ninja for your reply!
I’ll give it a try…
So like this then,
export function loginmain_click ( event ) {
let dataObj = $w ( ‘#signup’ ). hide ();
let user = wixUsers . currentUser ;
if (! user . loggedIn ) {
wixWindow . openLightbox ( “Login” , dataObj );
}
}
@ybmedia
All you have to do is —> send a specific value to the LIGHTBOX, which then will indicate the value and decide what to do on LIGHTBOX-CODE.
Example:
You click a button on your MASTERPAGE (HEADER) and generate the value = 1.
Then you open the lightbox while sending it that generated VALUE (1).
On the Lightbox-Code-Part you than write a function, which will start emmidiately in the —> onLoad()-part.
This function then will recognize what to do with the recieved VALUE–> 1 (on lightbox-side) by using a simple —> if(){} - else{} - query.
Something like…
$w.onReady(()=>{
let recievedValue = wixWindow.lightbox.getContent();
if(recievedValue===1){
$w("myElement").hide('fade')
}
else{console.log("Recieved wrong value, element cant't be closed!")}
});
The same way you can use for example the wix-storage, your database or the public JS-File.
@russian-dima Solid! Absolutely solid… Thanks a million.