Hello Wix team,
I am having an issue with a Slide Deck Gallery and deleting its item using wix code. I am using a delete button to delete the contents of the gallery with the following code.
export function imagedeletebutton_click(event, $w) {
let items = $w("#gallery").items;
let currentgallerindex = $w("#gallery").currentIndex;
//if (currentgallerindex === items.length) {
//
//
// items.pop();
// $w("#gallery").items = items;
//
//
//} else {
items.splice(currentgallerindex, 1);
$w("#gallery").items = items;
//}
}
The problem I am having is that:
If the gallery contains more than one image(I can delete the image if the gallery contains only one image.), I cant delete the last image in the gallery. If I try to delete the last image, the gallery turns to white colour and nothing is happening. I guess the gallery is crashing.
Here is the screenshot of the chrome developer console. its saying rendering failed when I tried to delete the last image by clicking the delete button.
Current situation
-
one image in the galery: delete operation works
-
Two images in the gallery: i can delete the first one without issue but if I delete second image, it crashes the gallery
-
Three images in the gallery: I can delete the first one or second one in any order. And when i try to delete the last image the gallery crashes
I tried using pop instead of splice as seen in the commented part of the code. But that time also I am not getting the expected result. Can anyone help me to solve this issue? Thanks.