Lightbox not working when submit is clicked

I am new to Editor X and Javascript. I am doing the front end tutorial to get an understanding of Editor X. Doing the Lightbox section but cannot get the popup to work when I click the submit button. Here is my code:

From the Main Page:

import wixWindow from ‘wix-window’ ;
import wixData from ‘wix-data’ ;

$w . onReady ( function () {

});

function submit ( ) {
$w ( ‘#movieSubmit’ ). onClick (() => {
let dataObj = {
“personalName” : $w ( “#addName” ). value ,
“movieName” : $w ( “#whatMovie” ). value
}
wixWindow . openLightbox ( ‘Popup’ , dataObj )
})
}

From the lightbox page:

import wixWindow from ‘wix-window’ ;
import wixData from ‘wix-data’ ;

$w . onReady ( function () {
let dataObj = wixWindow . lightbox . getContext ();

$w ( '#personalName' ). text  =  dataObj . personalName 
$w ( '#movieName' ). text  =  dataObj . movieName 

});

I have clearly missed something but cannot find it…

If I understand correctly you put a function in a function …


function submit () {
     $ w ('#movieSubmit'). onClick (() => {
       

The first function seems to be activated elsewhere, then you gift again on the condition that they press the frost again it will never happen.
Enough to put it this way:


$w.onReady(function (){
$w('#movieSubmit').onClick(() => {
         let dataObj = {
             "personalName": $w("#addName").value,
             "movieName": $w("#whatMovie").value
             }
         wixWindow.openLightbox('Popup', dataObj)
     })
});

AV digital. Thank you. I see what I did from your example. Made the change and it works. Learned from this. Again, thanks. My apologies for not getting back sooner…had a small pile of tasks to get done.

Glad to hear…
I think there is an option to mark the answer as a correct answer that can help the following users.