How to highlight selected items in repeater

I have a repeater on a container. The container has a row.

Each time the row is clicked on, the class “selected” is added.

But I have not figured out how to “unselected” the row that was previously clicked on. Any help would be appreciated!

Add a property to the data model called selectedRow. When a row is clicked, assign the current’s row object to selectedRow. In the highlighting logic (the Class Logic) check if the current row equals the selectedRow. If it does, use the highlighting class, otherwise, use the regular (non-highlighting) class.

Thanks @mark-piller .

For others who has the same question - Because I just wanted to add the “selected” class rather than replacing as Mark suggested, my first attempt ended up in the loop (stupid mistake on my part). To prevent it I added additional “if” statements for the Class List Logic.

During my debug I found another solution, which I found was simpler that takes advantage of custom code:

Screenshot 2023-12-04 at 17.44.54