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' );
});
});
- Pressing the delete button and getting the array in the console
- after clicking, the current item is .hide() and the function finds the current item in the array using the ID (using filter())
- trying to delete another item, Item is hidden in the currentIndex but is still showing in the array. : \