So I have a client who wants to delete and manage photos in a gallery field in a collection from the site itself. I can upload to the collection but i’m trying to delete a specific item from the gallery field with code. It is deleting and it says so in the verbose debug preview, but the cms is not changing at all. Any help would be appreciated. here is screenshots and my code.
import { local } from 'wix-storage-frontend';
import wixData from 'wix-data';
$w.onReady(function () {
$w("#gallery1").onItemClicked((event) => {
let index = event.itemIndex;
local.setItem("index", index);
$w("#button7").label = index.toLocaleString('en');
console.log("Gallery Item Title=" + event.item.title)
console.log("gallery#:", index)
let image = event.item.title
let imagecover = event.item.src
let eventname = $w('#button7').label
})
})
export function button7_click(event) {
let currentItem = ($w("#dataset1").getCurrentItem())
console.log(currentItem)
let index = local.getItem("index"); // "value"
currentItem.photos.splice(index, 1)
console.log("item removed")
$w('#button7').label = "item removed"
console.log("completed delete process")
wixData.update("photos", currentItem)
$w('#dataset1').save
console.log(currentItem)
}
When I select the image in the database
When I click the button to remove it.