Hi i am trying to send a string from a page to a lighbox...
the sender code is:
export function image39_click(event) {
let name = $w('#title').text;
local.setItem('targetName', name);
wixWindow.openLightbox('sendChat');
the receiver code in the lightbox:
let name = local.getItem('targetName');
$w("#text70").text = name;
The problem is that #text70 is not updated with the value of #title that i am trying to pass.
Is there something wrong in the code?
The only doubt i have is that in the source page i am using both {session} and {local} for 2 different data transfer: session to receive data from another page, and local to send data to the lightbox
session is different from local. but it looks as if you are using local correctly in your code.
In any case, I would recommend passing data directly to the Lightbox. Something like this:
To open the Lightbox:
let name = $w('#title').text; wixWindow.openLightbox("sendChat", {'targetName': name});
To get the passed data in the Lightbox:
let receivedData = wixWindow.lightbox.getContext(); $("#text70").text = receivedData.targetName;
OMG now it works :O i wonder how i could forget about it...
Thank you Yisrael, very much
The two lines of code that get the value, need to be in the onReady() function of the Lightbox:
$w.onReady( function() { let receivedData = wixWindow.lightbox.getContext(); $w("#text72").text = receivedData.targetName; } );
There might be other issues, but that one is obvious.