Hello everyone.
I’ve added items to an array using a checkbox inside a repeater. Now I want to remove the item from the array (using the _id). I’ve found a solution here: https://www.wix.com/velo/forum/community-discussion/how-to-remove-an-item-from-an-array but not sure how to implement it. My code:
function selectItem() {
let itemToAdd = {};
let sumTotal = 0;
$w("#selectItem").onChange((event) => {
const $item = $w.at(event.context);
if ($item("#selectItem").checked) {
let finalPrice = $item("#price").text * $item("#dropdown1").value;
$item("#ifMarked").text = finalPrice.toString();
let id1 = $item('#title').text;
let id11 = id1.replace(/\s/g, "");
let price = $item('#price').text;
let marked = $item('#ifMarked').text;
let catImg = $item("#vegNonVeg").src;
let qty = $item('#dropdown1').value;
//console.log(catImg);
itemToAdd = {
"_id": id11,
"catImg": catImg,
"price": price,
"qty": qty,
"title1": id1,
"ifMarked": marked
};
secondRepeaterData.push(itemToAdd);
console.log(secondRepeaterData);
} else {
//remove the item
}
});
}