Deleting a selected item from array and repeater

Hey, community!
i am trying (for 6h now) to delete an item from my array by pressing the delete button in my repeater.
i am getting the current item ID and i am able to delete the first item, but when i am trying to delete another item, nothing happens, and it looks like the id is stuck on my first selection.

this is my code:

import wixWindow from ‘wix-window’ ;
//Get data from book-online page

$w . onReady ( function () {

console . log ( userCart ,  "use" ); 

});

let userCart = wixWindow.lightbox . getContext ();
$w ( ‘#repeater8’ ). data = userCart

$w ( “#repeater8” ). onItemReady (( $item , userCart , index ) => {

$item ( "#image10" ). src  =  userCart.image ; 
$item ( "#text227" ). text  =  userCart.title ; 
$item ( "#text229" ). text  =  userCart.price ; 

//Remove item from repeater 
$item ( '#button11' ). onClick (( event ) => { 

    $item ( '#container7' ). hide ( 'slide' ); 

    **let**  ogRepeater  =  $w ( '#repeater8' ). data 
    **let**  newRepeater  =  ogRepeater . filter ( item  =>  item._id  !==  userCart._id ) 

    console . log ( userCart._id ,  'deleted item id' ); 
    userCart  =  newRepeater ; 

    console . log ( userCart ,  'new_uesrCart' ); 

}); 

});

  1. Pressing the delete button and getting the array in the console

  1. after clicking, the current item is .hide() and the function finds the current item in the array using the ID (using filter())

  1. trying to delete another item, Item is hidden in the currentIndex but is still showing in the array. : \

I would say, your steps seems to be logical, but maybe you forget the fact, that your onClick-Event is inside of…

$w("#repeater8").onItemReady(($item, userCart, index) => {

What if you reload REPEATER again with data, after you have got your new data???

something like …

$w('#myRepeaterID').data = [];
$w('#myRepeaterID').data = myNewGeneratedData;

This is my first though when i saw your code.

The idea behind is to RELOAD the REPEATER to trigger/activate the onItemReady-Event.

There are other possibilities…maybe…

  1. using forEachItem
    https://www.wix.com/velo/reference/$w/repeater/foreachitem

  2. using…