I have a repeater and when someone clicks a button inside the repeater I want to remove the clicked item. All items in the array have a _id field with 0,1,2,3,4,5,6 as strings.
cartArray holds all items and for some reason the click event gets triggered as many times as there are items in the array. It should trigger once and the splice would take out the correct item.
Are there any bugs in the new way of handling the repeaters?
$w("#cartRepeater").onItemReady(($item, itemData, index) => {
const deleteButton = $item("#rowDeleteButton");
$item("#rowItem").text = itemData.title;
$item("#rowSum").text = itemData.sum.toString();
deleteButton.onClick((event) => {
console.log("Item in cart clicked has index: " + index);
cartArray.splice[index,1];
console.log(cartArray);
});
});
Please someone.