domivax
September 9, 2019, 4:14pm
1
Dear All,
I read so many threads without finding a solution of my case. Reason I request your precious help.
I have:
A collection ‘Clients’ with fields ‘name’, ‘date of birth’, ‘address’, ‘country’
On page
A dataset ‘DatasetItems’
A repeater ‘Repeater’ showing only the data ‘name’ and a button ‘ButtonShowMore’
A lightbox ‘Customer’ with text field ‘TextDateBirth’, ‘TextAddress’, ‘TextCountry’
I would like, when opening the lightbox the other fields are shown on it
I tried this but it does not work
//PAGE CODE
import wixWindow from ‘wix-window’;
export function Container_click(event) {
let currentItemName = $w(’ #DatasetItems ‘).getCurrentItem();
let currentItemDateBirth = $w(’ #DatasetItems ‘).getCurrentItem();
let currentItemAddress = $w(’ #DatasetItems ‘).getCurrentItem();
let currentItemCountry = $w(’ #DatasetItems ').getCurrentItem();
wixWindow.openLightbox(“Customer”, {
“pageSend1”: (currentItemName.name),
“pageSend2”: (currentItemDateBirth.dateBirth),
“pageSend3”: (currentItemAddress.address)
“pageSend4”: (currentItemCountry.country)
})
}
// LIGHTBOX CODE
import wixWindow from ‘wix-window’;
$w.onReady( function () {
let received = wixWindow.lightbox.getContext();
$w(’ #Name ‘).text = received.pageSend1;
$w(’#DateBirth ’).text = received.pageSend2;
$w(’ # Address’).text = received.pageSend3;
$w(’ # Country’).text = received.pageSend4;
} );
Thank you for your help.
Best regards,
Domivax
For starters try actually defining what fields in your dataset that you want the getCurrentItem to relate too.
$w(“#dataset1 ”).getCurrentItem().fieldName;
Also… export function Container_click(event) { - should that not be the show more button?
Also again, check your code from openLightbox.
https://www.wix.com/corvid/reference/wix-window.html#openLightbox
Finally, if you are using a repeater then you will need to use onItemReady too
https://www.wix.com/corvid/forum/community-discussion/hide-button-boolean-wix-database
https://www.wix.com/corvid/reference/$w.Repeater.html#onItemReady
domivax
September 10, 2019, 4:47am
3
Thank you givemeawhisky,
I do not think that is mandatory to define the fields from the dataset because with the amended code below the data are displayed to the lightbox but not corretly because the data are displayed randomly. Indeed, if I click on the container of JOHN SMITH, the information of JUSTIN MOORE are displayed to the lightbox.
Why? What is missing in my code.
Thank you for your help.
Best regards,
Domivax
// PAGE CODE
export function Container_click(event) {
$w(“#RepeaterCutomer ”).onItemReady( ($item, itemData, index) => {
wixWindow.openLightbox(“Customer”, {
“SendName”: (itemData.name),
“SendDateBirth”: (itemData.datebirth),
“SendAddress”: (itemData.address),
“SendCountry”: (itemData.country)
})
})
}
// LIGHTBOX CODE
import wixWindow from ‘wix-window’;
$w.onReady( function () {
let received = wixWindow.lightbox.getContext();
$w(‘#Name ’).text = received.SendName;
$w(‘#DateBirth ’).text = received.SendDateBirth;
$w(‘#Address ’).text = received.SendAddress;
$w(‘#Country ’).text = received.SendCountry;
} );
You need to get the repeated item scope which is used to select a specific instance of a repeating element.