Hi there,
In this post, I am going to share a query of mine, from my website, for finding an answer.
In my website, there is repeater. And in the repeater, there is a button. When the button is clicked a lightbox will open.
Repeater and the button ---
Lightbox --
What I want is, when the button is clicked in repeater I want to get the current item (selected item ) from the repeater and change the value to the value the user submits from this lightbox.
Thanks,
Ajith
Hai Russian Dima
This Code Works Now !!!!
Page --
$w('#dataset2').onReady( () => { $w('#repeater1').forEachItem( ($item, index) => { $item('#button4').onClick((event) => { let clickedItemData = $item("#dataset2").getCurrentItem().status; let clickedItemData1 = $item("#dataset2").getCurrentItem().image; let clickedItemData2 = $item("#dataset2").getCurrentItem().fullName; console.log(clickedItemData); console.log(clickedItemData1); console.log(clickedItemData2); let lightboxdata = { "status": clickedItemData, "image" : clickedItemData1, "fullName" : clickedItemData2, } wixWindow.openLightbox('EditStatus', lightboxdata); }) }) } )
Lightbox --
import wixWindow from 'wix-window'; $w.onReady( function () { let received = wixWindow.lightbox.getContext(); $w('#textBox1').placeholder = received.status; $w('#image3').src = received.image; } );
The lightbox don't open
and I don't know if the data is send or not
Thanks,
Ajith
Hai everyone,
The following is my code of page and lightbox respectively ..
But the below code is not working !
Can you point out the mistake ??? 😀
Page -
export function button4_click(event) { wixWindow.openLightbox("EditStatus", { "pageSend1": $w("#dataset2").getCurrentItem.status(), "pageSend2": $w('#dataset2').getCurrentItem.image(), "pageSend3": $w('#dataset2').getCurrentItem.userId(), "pageSend4": $w('#dataset2').getCurrentItem.fullName() }) .then( (data) => { $w('#text16').text = data.lightboxSend1 $w('#image2').src = data.lightboxSend2; $w('#text18').text = data.lightboxSend3; $w('#text19').text = data.lightboxSend4; $w("#dataset2").setFieldValues( { "status": $w('#text16').text, "image": $w('#image2').src, "userId": $w('#text18').text, "fullName": $w('#text19').text } ); } ); }
Lightbox ->
export function button4_click(event) { let $item = $w.at(event.context); wixWindow.openLightbox("EditStatus", { "pageSend1":$item("#dataset2").getCurrentItem.status(), "pageSend2": $item("#dataset2").getCurrentItem.image(), "pageSend3": $item("#dataset2").getCurrentItem.userId(), "pageSend4": $item("#dataset2").getCurrentItem.fullName() }) .then( (data) => { $w('#text16').text = data.lightboxSend1 $w('#image2').src = data.lightboxSend2; $w('#text18').text = data.lightboxSend3; $w('#text19').text = data.lightboxSend4; } ); }
Thanks ,
Ajith
I will comment if there is any error
Thanks !!😀
Thank You very much Russian-Dima,
This is what I was trying to achieve!!!!!
Just look in your followers - There will be a name 'Ajith'
Thanks!!!!
What I need is the save (update ) the current item function code
Exactly ! Accurate ....(no other words)!!!!
It is right !!!!!
Hello Everyone,
What is was actually asking is when the user clicks the button on the repeater , I want to get the items and transfer that items to lightbox. In the lightbox I want to update the data to what to user types in the lightbox
--
So Thanks
Ajith
In the wix documentation there is information that the onClick event does not work when calling the getCurrentItem function. He seeks only the first item. So, the solution for your case is as follows:
exportasyncfunctionpickupButton_click(event){let $item = $w.at(event.context); console.log($item("#dataset1").getCurrentItem());
Hai Russian-Dima,
Glad you have helped here !
But there is more !!!
This a part of my code of the page -
export function button4_click(event) { let currentItem = $w("#dataset2").getCurrentItem(); wixWindow.openLightbox('Edit Status', currentItem) }
Lightbox code -
export function button2_click(event) { let receivedData = wixWindow.lightbox.getContext(); console.log(receivedData); if (receivedData) { let toUpdate = { //update data }; wixData.update("UserStatuses", receivedData._id) .then((results) => { console.log("item was removed"); wixWindow.lightbox.close('ok'); wixLocation.to(`/statuses-page`); }) .catch((err) => { console.log("error: " + err); wixWindow.lightbox.close('error'); }); } else{ console.log('item was not sent'); } }
2) How can I update the two values received from the page ???
Thanks ,
Ajith
Anyone Please Help Here !!
Ajith