I found my mistake seconds after posting this. But, I will leave this up incase others can benefit. It was the $item conundrum. I had not seen that I did not label the box as $item.
This…
const repeatedDetailBox = $w('#detailBox');
Needed to be this…
const repeatedDetailBox = $item('#detailBox');
Original Post:
I can’t see the forest for the trees. In my repeater I have a button that toggles a box (detailBox) with “more detail” about an event. The onClick event should only expand the box in the selected item, not all of the similar detailBoxes in all the items in the repeater. I am using the $item reference which would typically be the reason this would have created an event that affected all items (I think). I have successfully done this type of event in a repeater in the past. In fact, a different version of this was working until this morning when I changed my icon and rewrote the code. I may be missing something so obvious simply because I have been looking at this too long. Can you see my mistake and help me? Thank you.
Repeater shown below. Button with arrow (detailButton) should cause the detailBox to expand only in the item where the button was clicked. But clicking any detailButton expands the detailBox in ALL items.
Code:
This is a snippet from the larger code. I have highlighted the part I think needs work.
$w.onReady(function () {
$w("#varRepeater").onItemReady(($item, itemData, index) => {
if (itemData.home === true) {
$item("#ishome").text = "vs. "
}
else {$item("#ishome").text = "@ "}
const repeatedLocationName = $item("#locationName");
const repeatedAddress = $item("#address");
const repeatedDescription = $item("#description");
const repeatedDetailButton = $item("#detailButton");
const repeatedDetailBox = $w('#detailBox');
//Populate location name and address elements
repeatedAddress.text = itemData.location;
repeatedLocationName.text = itemData.locationName;
//Show theme/description of game if there is one
if(!itemData.description) {
repeatedDescription.collapse();
}
else (repeatedDescription.expand())
//Detail Button
repeatedDetailButton.onClick((event) => {
if(!repeatedDetailBox.collapsed) {
repeatedDetailBox.collapse();
}
else {repeatedDetailBox.expand();
}
} );
#repeater,#items,#$item,event,#event_handler,