Confirm "delete" when using the delete button?

Is there a built in way to warn a user that a delete will occur and get confirmation when using the dataset “Delete” button?

For the “Submit” button, there is a built in way to confirm submission or warn of an error. A nice feature would be able to request confirmation.

If this is not available, how can I generate my own confirmation message (popup) that forces the user to click “yes” (to continue) or “no” (to go back (not revert))? I assume I just need to do something with onClick? But then want the built in delete to execute on yes. Thoughts?

Thanks!

Hi dmz,
The Submit button has a build in way by adding a text message and show it when clicking on it. You can create an onClick event for that button, add a text box with the relevant message and hide it on load. Once the user clicks on the button, you can show the text.

If you wish to generate a pop up, it’s basically opening a lightbox when clicking on the button (onClick event).

Which way do you prefer? Moreover, just to be sure I understand the scenario properly- you refer to deleting a record from the collection, right?

Thanks,
Tal.

Thanks for the help. Yes, this is for deleting a record in the collection.

As to which I prefer, either works but I would like to try both to see what I think?

Ok, can you please send me the site URL so that I can have a look? How do you get the record information (the one that you wish to delete)? Just so that I can understand the whole scenario and provide you with the relevant code :slight_smile:

I really appreciate it - Thanks! :slight_smile:

Site URL is: https://fatdads.wixsite.com/fat-dads-website

It is a private site for a vets football team.

To get to anything of interest, you must be a member of the team. I can approve an account if you sign up or you may be able to get there without it as a mod?

The page that I want to add a confirmation message on delete is " Update Services " page. I filter the records so that only the logged in members records are available. All I want is a popup (or message) that confirms the user want to delete a record.

We have a mailing list for the team and people are always asking for recommendations for mechanics, plumbers, babysitter, etc. so part of the site allows team members to share recommended businesses in the area.

Hope this makes sense. Any questions, just ask. Many thanks!

Hi,

You can achieve that by showing the real delete button only when the first button is pressed:

export function deleteBtn_click() {
	//delete button was clicked, hide it and show confirm text and button
	$w('#deleteBtn').hide();
	$w('#confirmText').show();
	$w('#confirmBtn').show();
}

export function confirmBtn_click() {
	//confirm button was clicked, hide the text and button and delete the current item
	$w('#confirmBtn').hide();
	$w('#confirmText').hide();
	$w('#dataset').remove()
}

That is a cool solution. :slight_smile: Very clever…That is one reason I love code - to see how others solve things.

Many thanks!!

I still cannot get this to work all the way…I did the above and also added a cancel (no) button.

When I click on “yes” - the record is deleted but the yes, no and text remain and the delete button is not shown. Any ideas on what I have done wrong? Thanks!

export function deleteBtn_click() {
	//delete button was clicked, hide it and show confirm text and yes / no buttons
	$w('#deleteBtn').hide();
	$w('#deleteConfirmText').show();
	$w('#confirmBtn').show();
	$w('#cancelBtn').show();
}

export function confirmBtn_click() {
	//"Yes" button was clicked, hide the text and Yes and No buttons and delete the current item
	$w('#confirmBtn').hide();
	$w('#cancelBtn').hide();
	$w('#deleteConfirmText').hide();
	$w('#deleteBtn').show();
	$w('#dataset1').remove();
}

export function cancelBtn_click() {
	//"No" button was clicked, hide the confirm text and buttons 
	$w('#confirmBtn').hide(); 
	$w('#cancelBtn').hide(); 
	$w('#deleteConfirmText').hide(); 
	$w('#deleteBtn').show();
}

It worked fine!