I’m trying to open a lightbox with some parameters affecting the lightbox content. This should be pretty straight forward, but I can’t get it to work. To be more precise - clicking the lightbox-opening button seems to work only after trying a few times…
Here’s my code for opening the lightbox:
export function button1_click(event) {
if (wixUsers.currentUser.loggedIn) {
let name = $w('#audioPlayer1').trackName
let info = $w('#text40').text
let guid = $w('#text41').text
let data = {'name': name, 'info': info, 'guid': guid}
wixWindow.openLightbox('info_box', data);}
}
And here’s (part of) my lightbox code:
import wixData from 'wix-data';
import wixWindow from 'wix-window';
import wixLocation from 'wix-location';
$w.onReady(function () {
$w('#text38').hide()
let received = wixWindow.lightbox.getContext();
$w('#text37').text = received.name
$w('#textBox1').value = received.info
$w('#text38').text = received.guid
});
The lightbox however, is showing default text/value strings instead of the passed fields in “received”… What am I doing wrong??
Any help would be very much appreciated…
Anyone? Anything? Is there maybe a more official support system I can contact as a paying user?
This is really disrupting my work flow, and the button only works properly if I try 3 or 4 times. Any help would be very very much appreciated!
I don’t see anything obvious in the code that you posted. The only thing that I see is how you’re building the data object to be passed.
You did it this way:
let data = {'name': name, 'info': info, 'guid': guid}
I usually build it without the keys in quotes:
let data = {name: name, info: info, guid: guid}
Seems that it should be OK either way.
Please post your site URL and explain where and how to see the problem.
I’m not sure how to properly describe the problem, especially seeing as the site’s in hebrew, but I’ll try:
The site is www.haravyosefkalner.com, and on the page https://www.haravyosefkalner.com/searchable-sdarot/ there’s a button named ערוך , as seen in image-1:
Choosing a line from the table below changes the white text-box content to the relevant field in the table columns. For instance one might choose the following line -
which would in turn change the aforementioned white text box to -
The point of the ערוך button is to allow for editing this field. So clicking on the button opens a lightbox, as so -
But the fields here are all showing the default text-box strings and values! While the code-snippets I posted should be passing and updating these fields such that they’d show the current white-text-box string that would then be edited by the user and saved to the collection.
I’ve checked with debugging tools, and things are being pipelined properly, it’s just that it seems like I maybe need to add some kind of delay somewhere? I really don’t know.
(P.S: this is just the more simple format, but I’ve got a similar problem with another site functionality, and I’m kind-of hoping that this problem+solution would maybe shed light on the other problem. Just in case this context helps a bit).
You are opening the Lightbox in two places:
In the button1_click() event handler, you are opening the Lightbox if the user is logged in.
However, you also have the button set to open the Lightbox when the button is clicked. When the button is clicked, it will open the Lightbox without passing it the appropriate data. Also, this causes a conflict with the button1_click() function. You need to unlink the button from the Lightbox.
Ah! I didn’t have an “else” clause, and I’m usually signed in by default, so I was assuming that the lightbox opening was a matter of entering the user-is-logged-in condition. While what was actually happening was that I was logged out, and the lightbox was opening due to the gui-api linking…
Thanks a million!