Clients introduce their items and appears in their own log in user repeater, can I create a button to allow my clients to delete items? do I need wix code? thank you
did you get an actual answer on this question?
Regards
Adam
give the correct permissions in your collection to allow the user to delete items then place a button on your repeater and code something like this…
$w($w.onReady(function () {
// change the following varibles as required for your site (deleteButton1, dataset1, myCollection1)
//make sure the user has been given the correct permissions to allow deleting items from your //collection/database
$w('#deleteButton1').onClick((event) => {
$w("#dataset1").onReady(() => {
//get ID for repeater item when clicked
let $item = $w.at(event.context);
let currentItem = $item("#dataset1").getCurrentItem();
let itemID = `${currentItem._id}`;
console.log(itemID);
wixData.remove("myCollection1", itemID)
.then( () => {
console.log("item removed from collection/database");
$w("#dataset1").refresh();
});
})
})
})
thanks very useful
Hi Mike, is it possible to put a lightbox in front of this code to give the user a choice to delete the repeater? The code works fine by the way for the functionality you posted
@Adam
Why don’t you just put a button on the page and create an onClick event for the button to hide the repeater
Thanks Mike, i did wish to enable a user to delete and have overcome this issue by using two buttons. one to load a lightbox and another to actually delete the repeater item.
@mikemoynihan99 Hi, what if I use a query to populate my repeater. I didn’t use a dataset and I would like to have a delete button on my repeater, what would the code be? I hope you could help me.
@mikemoynihan99 Hi, could you explain what the difference is between your versions of dataset1 and mycollection1 are? i assumed they were the same thing?