I’ve added a repeater to allow users to add guests. Inside each container is a delete button.
For some reason that I can’t figure out it’s running 3 times every time I click on delete regardless of how many entries are in the array. Can anyone see what I’m doing wrong?
export function deleteGuest_click(event) {
$w('#addGuestTick' ).enable();
let $item = $w.at(event.context);
let guestId=+$item('#guestId').text;
let x=guestId;
console.log(guestId);
for (let i = x; i < guestsData.length-1; i++) {
guestsData[i].guestName = guestsData[i + 1].GuestName;
}
guestsData.pop();
$w("#guests").data = guestsData;
$w("#guests").forEachItem( ($item, itemData, index) => {
$item("#guestName").text = itemData.guestName;
} );
if (guestsData.length==0) {
$w("#guests").collapse();
}