Hi there, is it possible to pass the the checkbox value from the light box to tag values in page?
I want to pass the checked values of CHECKBOX GROUP (in lightbox) to the tag values (in page). How can I get the values seperately? Here is my code. Lightbox code:
import wixWindow from 'wix-window'; import wixLocation from 'wix-location'; import {session} from 'wix-storage'; $w.onReady( function () { } ); export function saveButton_click(event) { console.log($w('#checkboxGroup1').selectedIndices); session.setItem(1,$w('#checkboxGroup1').value); wixWindow.lightbox.close(); } Page code:
export function option2_click(event) { wixWindow.openLightbox("Field") .then( (data) => { let update = session.getItem(1); //$w("#selectionTags1").options = update; let TagOptions = $w("#selectionTags1").options; TagOptions.push({'label':'A', 'value':'a'}); //I want to show checked values seperately by tags here. $w("#selectionTags1").options = TagOptions; } ); } Thanks
To pass data back to the page that opened the lightbox, you must close the lightbox programmatically using the close() function. Something like this:
wixWindow.lightbox.close(dataObj);
(where dataObj is an object with the values to be sent back to the page)
The openLightbox() function returns a Promise which is resolved when the lightbox closes. You can retrieve the data passed from the Lightbox to the page in the Promise. Something like this:
wixWindow.openLightbox("LightboxName") .then( (data) => { let receivedData = data; // data passed back from the Lightbox } );
You can see how values are passed to and from the Lightbox in the Slot Machine example.