I am new to Wix and I am just in the verge of learning using its APIs.
I want to open and send data to a Lightbox with the codes below:
import wixWindow from 'wix-window'; $w.onReady(function () { $w("#button2").onClick( (event, $w) => { let strAppleMusicPreviewUrl= $w('#dataset1').getCurrentItem().appleMusicPreviewUrl; console.log(strAppleMusicPreviewUrl); wixWindow.openLightbox("SongPreview", strAppleMusicPreviewUrl); } ); });
The code works perfectly in Preview mode but it does work in the Published site.
Any idea how to make it work?
Thanks,
Marconi
Thanks stcroppe! Appreciate your inputs. You are right on spot. I will keep that in mind.
Cheers!
Marconi
The original code will likely work if you put it in the dataset's onReady()
So
$w.onReady(() => { $w('#dataset1').onReady(() => { $w('#button2').onClick((event, $w) => { }); }); }
The reason being that the button is part of a repeater that depends upon the dataset items. The if you don't wait for the dataset to load before setting up the handlers they may not work as expected.
Hope that helps.
Hi Majd,
Thank you so so so much. It is now working as i expected it to be. i did not know how to add the "button2_click()" event handler until now.
Cheers!
Marconi
Hello Lucas,
I changed your event to be not in the $w.onReady(), but as a separate event function and it seemed to work.
Here is a screenshot:
Best,
Majd
Hi Roi,
The 'Listen to Preview' button works if I navigate to other page and then click the 'Back' button of the browser. After this, only then that the 'Listen to Preview' button works.
I don't know how to fix this.
Thanks,
Marconi
Hi Roi,
Thanks for your response.
Here is the page that is suppose to use the Lightbox
https://lucas-marconi.wixsite.com/website/songs-via-marconi
If you click 'Listen to Preview', it should pop up Lightbox with an HTML component that contains the player to the song.
It works properly in Preview mode but when Published, the button does nothing when clicked.
it has been 3 days now trying to fix it :(
regards,
Marconi
Hi Marconi,
The code looks good.
Can you please share a link to your site and specify the name of the page so we can inspect?
Roi.