Having info in a member only view repeater delete on click

I have the following code which works on preview:

export function deleteButton_click(event) {
//Add your code for this event here:
let item = $w(“#dataset3”).getCurrentItem();
wixData.remove(“savedAddresses”, item._id);
setTimeout (() => {
$w(‘#dataset3’).refresh();
}, 200)
}

The button is inside the repeater box that should have the info deleted. It only doesn’t work on live site for some reason.

Any help would be awesome!

Thanks!!!

So, it doesn’t work on live site? You may want to check your database permissions (who can delete, edit, etc the database).

Also, why can’t you just connect the button to the delete action? I think that should work without coding everything. Having everything aside from the button to be ready-only. Make the database read & write.

Issue was with permissions. Had who can delete as Admin only instead of site member.

Thank you!!!

on a separate issue if you have time,

when a user is logged in on my site, I redirect them to their profile page; however, it seems that whenever they switch pages they automatically get logged out and need to log back in. Any way to fix this?

thank you in advance!

@anneynorton7 Interesting. I am not sure about that. What is the purpose for redirecting them to the profile page? Maybe there’s a workaround.

@brettfranklin2 Actually solved the problem haha.

The full issue was that I had a profile button that you would click on to make a get a user to their login page/profile (if logged in) I wrote the code for that, but it kept going to the login page even if the user was already logged in and wanted me to re-login. Turns out I forgot to unlink the image from that login page (it had been linked for testing a while back).

I know this response is really old but I’m wondering, if you are still connected here, if you could tell me how you would do this? I have a section inside my member pages that is linked to a CMS dataset where documents are stored (these are files uploaded by members, and each member can only view the files that they themselves have uploaded).

I want to add a button to the repeater where I have these files appearing that also allows the member to delete a file that appears in their list of previously files. How do you do this using the “delete action” you mention in your reply, rather than using code?

I thought I should post an update, in response to my own question-in case anyone reads it and is still looking for an answer…
The issue was with my CMS and in-page dataset permissions. Once you add advanced permissions to the CMS table (including the right to “delete”), as well as read-write permission on the dataset where it is linked on the web page, the delete action then appears as an option for the button linked to the dataset.

I’m now working on trying to figure out how to add an “are you sure” pop up when a member clicks the delete button. This post has the answer in code, I now need to figure out how to get it to work on my page: Confirm "delete" when using the delete button? - #6 by admin-23