NO UNIQUE IDs!!!! For Buttons In One Repeater!

Hello,

This is being posted to Wix Code Forum and Wix Experts support for best results as I am not sure who can best advise me on what I need to do the way I am stuck here.

I was trying to use some buttons on repeaters with Code to do things for me, then I find out all buttons in the same repeater must used the same exact ID. If I am trying to use the buttons with code, all buttons will have to do the same thing while if I just linked to a static page with editor controls, I could connect those buttons on the same repeater to different pages.

I need unique IDs assigned to buttons inside a repeater to work with Wix Code.

Repeaters located at https://www.symmetracreative.com/affordable-business-cards-houston.

original thread of what I was going to do with these buttons. but now I am defeated in wasted time and effort once more thanks to this completely baffling logic of the repeater. All my buttons in each of those 4 columns (4 repeaters vertically) share the same exact id and when I change anyone all the other ones change with it too, then how am I supposed to connect them to code one at a time!

Thanks
Omid

1 Like

I can confirm this unqiue id problem exists for all elements inside of a singular repeater, text, image, whatever, it will have this problem and thus cannot be manipulated with Code or even integrated with Code to do anything from what I can see.

I read this entire thing and still feel just as confused as to how am i supposed to handle this need.
https://www.wix.com/code/reference/$w.Repeater.html :confused: I cannot help but feel as though this is a limitation by design (or an underthought/oversight?) that is going to impose needless complication to the level of coding required just to get a unique id to an element in a repeater adn get it to trigger unique actions. #feelsbadman

Hi,
You should set data to a specific repeater element using the $w variable (using the onItemReady function). The $w variable is the scope of the specific element. I recommend reading documentation and the examples of this specific function.

Best,
Tal.

Omid, a long time ago I was struggling with that beast too. Then Tal pointed me to an earlier contribution of hers that I missed. Maybe it works for you too.

Not sure if this has been said like this exactly, but my use case was that I wanted to be able to disable a button in a repeater container but just that button (while the other buttons in the repeater remained enabled). I accomplished this by creating this function on all of the "#bookButton"s that matched the event.context.itemId which maps to the particular button clicked to that itemData._id in the repeater.

export function bookButton_click(event) {
// #slotRepeater is the id of my repeater
$w( “#slotRepeater” ).onItemReady(($item, itemData, index) => {
if (event.context.itemId === itemData._id){
// #bookButton is the id of all the buttons but $item maps through each button on the repeater
$item( “#bookButton” ).disable();
}
});
}

Hope this helps someone!

Thanks, Grace! We appreciate your contribution.