Hi there. Sorry Wix beginner here.
Basically what we are trying to achieve is to have a site which lists down the items that we have and to allow visitors to click on a button in order to email us for a quote via lightbox.
So we have a dynamic page which lists down the items we have from a dataset. This is done via Dynamic Pages. So it displays like 5 rows of items which we have with all the details. And there is a button in each row for users to click and this will link to a lightbox. However I would like the lightbox form to display the part number (or any other information) of the item. I tried but seems unable to achieve this - looks like the part number (pn) is not being passed over to the lightbox form.
Below is the code on the dynamic page showing the items which we have.
import wixData from 'wix-data';
import wixWindow from 'wix-window';
<this section is just for us to do a filter search, please ignore>
export function button2_click_1(event) {
let value = $w("#input1").value;
let filter = wixData.filter();
$w("#dynamicDataset").setFilter(
filter.contains("pn", value)
);
}
//export function button5_click(event) {
//let scope = $w.at(event.context);
//let records = scope('#dynamicDataset').getCurrentItem();
//wixWindow.openLightbox('Subscribe (Grayscale)', records);
//}
<this section is the onclick event for the lightbox to appear>
$w.onReady(function () {
$w('#button5').onClick((event)=>{
let $repeaterItem = $w.at(event.context);
let pn = $repeaterItem('#text13').text;
wixWindow.openLightbox('Subscribe (Grayscale)',pn);
});
});
Below is the code on the lightbox. When we click on the button (button5) the lightbox appears but the part number is not passed through to the lightbox form.
import wixWindow from 'wix-window';
$w.onReady(() => {
let records = wixWindow.lightbox.getContext();
let pn = records['pn'];
$w('#text15').text = pn;
});
text15 is where the part number(pn) is supposed to appear.
Not sure which part I got wrong. Any help would be greatly appreciated.
Check here -> https://www.wix.com/corvid/reference/wix-window/lightbox-obj/getcontext
Try this ->
#repeater1 - repeater
#button5 - button in the repeater
$w.onReady(function () { $w('#repeater1').onItemReady( ($item, itemData, index) => { $item('#button5').onClick( (event) => { let pn = $item('#text13').text; wixWindow.openLightbox("LightboxName", pn); }); }); });
Lightbox -
$w.onReady(function () { let records = wixWindow.lightbox.getContext(); let np = records.pn; $w('#text15').text = pn.toLocaleString(); });
Thank you.
Yes i screwed up. The issue is how I receive the data.