Is there a way to retrieve the item that is clicked in a repeater? I see that repeaters behave differently than tables but they are so much more aesthetically pleasing. I want to be able to perform a task based on the item that is clicked in a repeater.
top of page
Important forum update
This forum is migrating to one unified Wix community forum starting July 26th, and will be read-only during the process.
![feature fixed.png](https://static.wixstatic.com/media/3bfa8a_f845e1016b8a49758acdd6edd6610c3b~mv2.png/v1/crop/x_0,y_2,w_852,h_508/fill/w_104,h_62,al_c,q_85,usm_0.66_1.00_0.01,enc_auto/feature%20fixed.png)
Wishlist Page is the official platform for requesting new features. You can vote, comment, and track the status of the requested features.
bottom of page
Old post, but just in case, use the event action of any items integrated to a repeater :
export function whateverElement_onClick(event) { let $item = $w.at(event.context) const data = $w("#repeater2").data; let clickedItemData = data.find(item => item._id === event.context.itemId); //console.log(clickedItemData._id) == "MY165ID" }
What do you mean by putting the results?
Assuming you're connecting the repeater to a dataset, you could have a button (or any other linkable element) wired to link to the item's dynamic page.
It is possible to put the result into a dynamic page (Profile Page)?
Thanks Andreas and Shay! Both contributions worked perfectly! Exactly what I needed.
Thanks Shay for the perfect answer, I just added this event to any button or element inside the repeater.
export function plusButton_click(event, $w) { // Get clicked item let currentItem = $w("#dataset1").getCurrentItem(); console.log("Choosen data record is: " + JSON.stringify(currentItem)); }
And I also discovered through you that Textinputs are not supported within a repeater element. Thanks a lot for always great support.
Hey
Ok, it works when clicking in the container but if I want to have an add and a subtract button inside a repeater and when clicking the + button add some stuff and know the _id of the clicked item how to proceed?
Does the container click occur even if an object is clicked inside the container? Yes it does so first the container event occurs and then the element click event.
So I add the clicked item using getCurrentItem and store that in session on local or just in global variable. The issue then is that as you see below the Textinput field should be increased when clicking and when the user clicks they all got increased in all items inside the repeater. Any way around this?
Repeaters are built using Containers. Add a click event to the container and continue from there.
export function container1_click(event, $w) { //Log the current item of the container. console.log($w("#dataset1").getCurrentItem()); }
I am on it
The same here, investigating like crazy