I have a lightbox which people can select tags and a dynamic page (All). The selected tags are used to construct filter of a repeater. I managed to get the value from the lightbox to page, however I cannot not get the value out of the “function”. Here are my codes.
On Page:
(data.lightBoxSend1 is the selected tags value)
export function button15_click(event) {
wixWindow.openLightbox("Select Location")
.then( (data) => {
let selectedLocationTags = data.lightBoxSend1;
});
}
When I construct the Filter (It is just a part of the filter function):
if (selectedLocationTags.value.length > 0) {
dataQuery = dataQuery.hasSome('location', selectedLocationTags.value);
}
It shows that “selectedLocationTags” is undefined.
So, my question is How to get the value out of the “export Function” mentioned above?
Thanks in advance.
What parameter did you supply to the lightbox.close function? Placing a console.log(data) after the .then() function will help you understand the structure of the data being returned from the lightbox.
These are the code of lightbox.close function:
export function button14_click(event) {
let selectedLocation = $w("#selectionTags1").value.concat($w("#selectionTags2").value, $w("#selectionTags3").value)
wixWindow.lightbox.close({
"lightBoxSend1": selectedLocation,
});
}
How console.log(data) can help me to solve the problem?
Could you explain in more detail please?
@manhob888 It helps verify what you “think” is being returned from the lightbox.
export function button15_click(event) {
wixWindow.openLightbox("Select Location")
.then( (data) => {
console.log(data);
let selectedLocationTags = data.lightBoxSend1;
});
}
In what function is the filter code? Though I don’t know everything that you’re trying to do to make this work with the page elements, it seems that your filter code should be in the .then() function section. That’s where the value of selectedLocationTags is being assigned. Outside of the .then() function the rest of the page code cannot access the value of selectedLocationTags.