Hi Community,
I want to create a delete button for dynamic page that will remove the uploaded file from the collection.
The code below gets the right file from the database but it does not remove it for some reason.
Does anybody have an idea where is the mistake?
$w.onReady(function () {
$w("#dynamicDataset").onReady( () => {
let itemData = $w("#dynamicDataset").getCurrentItem();
let idToDelete = '';
//Gets the item
idToDelete = itemData.uploadedFile;
$w("#deleteWaterUseFile").onClick( () => {
//Check that idToDelete has info in it
if (idToDelete !== '') {
//Removes the entry from the database
wixData.remove("Applications", idToDelete)
.then(() => {
console.log("Removed from database: " + idToDelete);
//Resets the variable
idToDelete = '';
})
.catch((err) => {
console.log(err);
});
}
});
});
});