Iframe inside of Lightbox

Question:
I have been working on a coded form, and I embedded that code into an Iframe inside of a lightbox. I am trying to make my code communicate with the lightbox so that once the user clicks the last submit button in the embedded form it will close the lightbox but stay in the same page. anyone know what the correct code is?

Product:
I am working on Wix Studio

What are you trying to achieve:
Close a lightbox from embedded code.

What have you already tried:
I have tried some of the velo options but nothing seems to work.

import wixWindowFrontend from ‘wix-window-frontend’;

wixWindowFrontend.lightbox.close(dataObj);

You will first have to establish a communication between HTML-Component (iFrame) and your Wix-Page.

https://www.wix.com/velo/reference/$w/htmlcomponent/postmessage

Second step will be to add some further code, which would send a specific signal/sequence to tell your page to close the lighbox.

Example…

let outputData = {};
outputData.lighboxID = ‘myLighbox1’;
outputData.lighboxCommand = ‘close’;
outputData.lightboxContext = ‘add context here if needed’;

Now you have created your COMMAND-OBJECT, which holds all informations for your lighbox on your wix-page.
Now you send this object over to your wix-page. Your Wix-Page will recieve these object, will read out all the included values of that object and at least will handle each of the commands.

  1. selecting the right lightbox → data.lightboxID
  2. fullfilling the right command → data.lighboxCommand = ‘close’
  3. …and so on…
1 Like

I think, taht was you…

:grinning:

1 Like