in the past iโ€™ve handled this with the actual button changing copy to โ€œAre you sure?โ€ so they are forced to double click the same button (with some throttling so itโ€™s not on accident). I think a modal is probably a better way, but there is more context needed as to how important the information is and if itโ€™s possible to undo. Answer from real-cool-dude on reddit.com
Discussions

forms - Delete confirmation for items within a modal - User Experience Stack Exchange
I have a modal that contains a table of items. Each item is in a row and a user should be able to edit/delete each item. When deleting an item, there needs to be a confirmation dialog asking the us... More on ux.stackexchange.com
๐ŸŒ ux.stackexchange.com
August 26, 2021
Delete data with confirmation modal - javascript
I want to delete selected data with confirmation modal but somehow it only deletes the latest data not the selected data. Maybe there's something with the JavaScript logic but I can't seem to find More on stackoverflow.com
๐ŸŒ stackoverflow.com
interaction design - modal inside a modal (delete confirmation) - User Experience Stack Exchange
I have a View/Edit button which shows the details ofuser in a modal when clicked. In modal it has Save and delete buttons. When they click on delete button the user will be deleted. Before they del... More on ux.stackexchange.com
๐ŸŒ ux.stackexchange.com
Simple Bootstrap 4 Modal Delete Confirm - General Web Dev - SitePoint Forums | Web Development & Design Community
Hi All I am trying to work this out and have found lots of posts about something along the lines of what I want to do but not what I wantโ€ฆ I hope there is a very simple option. I want to add a delete confirm box (modal) to confirm a delete before deleting something. More on sitepoint.com
๐ŸŒ sitepoint.com
0
March 25, 2019
๐ŸŒ
Reddit
reddit.com โ€บ r/ui_design โ€บ how to handle delete confirmation from within a modal?
r/UI_Design on Reddit: How to handle delete confirmation from within a modal?
August 14, 2021 -

When you click on a task in my app it brings up a details modal showing all the info about the given task. From within the details modal I want to be able to delete the task, and I want to ask for confirmation when I do. I can't find a great way to handle this, a secondary modal popping up, overlay the original modal, a popout from the button, etc.

Trello uses the popout design you can see below, it works alright but doesn't feel right to me for some reason so I'm looking for other options hopefully with an example if possible!

๐ŸŒ
Dribbble
dribbble.com โ€บ search โ€บ delete-confirmation-modal
Browse thousands of Delete Confirmation Modal images for design inspiration | Dribbble
Explore thousands of high-quality delete confirmation modal images on Dribbble. Your resource to get inspired, discover and connect with designers worldwide.
๐ŸŒ
Bootstrap Examples
bootstrapexamples.com โ€บ @alaric-sloane โ€บ delete-confirmation-modal
Delete Confirmation Modal - Bootstrap 5 Example
โ†’ Delete Confirmation Modal ยท Favorite ยท This bootstrap css example is contributed by Alaric Sloane, on 02-Oct-2024. Component is made with bootstrap css v.5.3. It is responsive. similar terms for this example are popup,dialog ยท Tags: Modal ยท Author Alaric Sloane ยท
๐ŸŒ
DEV Community
dev.to โ€บ raselmahmuddev โ€บ a-custom-reusable-delete-confirmation-modal-hook-in-reactjs-1gic
A Custom Reusable Delete Confirmation Modal Hook in ReactJS. - DEV Community
October 9, 2025 - Instead of scattering modal state logic across every component, we can centralize everything in a single, reusable hook. With useDeleteConfirmation, requesting a confirmation becomes as simple as calling one methodโ€”no extra state, no repetitive boilerplate. ... deleteConfirmation.requestConfirmation({ title: "\"Are you sure?\"," message: ( <>This action is permanent and cannot be undone.</> ), actions: (onConfirm, onCancel) => ( <> <button onClick={onConfirm}>Yes</button> <button onClick={onCancel}>No</button> </> ), onConfirm: (close) => { // Your delete logic (e.g., API call) close(); // Always call close() to dismiss the modal }, });
Find elsewhere
Top answer
1 of 5
1

The problem is that your modal is outside of your for loop and that you are trying to access the $user variable in your modal. At this point in time the $user variable contains the last element of your for loop, because your loop has already iterated. That is the reason why you are always deleting your last user.

There are 2 options:

  1. Put your Modal code into your loop (this will create a modal for each entry)
  2. It is good practice to only have one modal and change the values dinamically (like you wanted to do). But for that you will have to pass/build the correct delete URL in your on click method

Give your form an id like id="delete-form" afterwards in your onclick method you can set the action dinamically:

$('#delete-form').attr('action', '/users/' + delete_id);

2 of 5
1

First, you did not name data-target="#exampleModal" it correctly. You must also enter the value of $user->id. Change it to data-target="#exampleModal{{ $user->id }}". Like this:

<a href="{{ '#' }}" class="delete-modal badge btn-danger" data-value="{{ $user->id }}" data-toggle="modal" data-target="#exampleModal{{ $user->id }}">

Secondly, You should put modal code in loop:

@foreach ($users as $user)
    <div class="modal fade" id="exampleModal{{ $user->id }}" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
        <div class="modal-dialog modal-dialog-centered modal-sm">
            <div class="modal-content shadow-sm">
                <form action="/users/{{ $user->id }}" method="POST" class="d-inline">
                    @method('delete')
                    @csrf
                    <div class="modal-body">
                        <h3 class="text-center">Are you sure?</h3>
                    </div>
                    <div class="modal-footer justify-content-around pt-0 border-top-0">
                        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                        <button type="submit" class="btn btn-danger" name="delete_user">Delete</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
@endforeach

Also pay attention to id tag: id="exampleModal{{ $user->id }}"

๐ŸŒ
ReadymadeUI
readymadeui.com โ€บ tailwind โ€บ component โ€บ confirm-delete-modal
Confirm Delete Modal | ReadymadeUI
This modal is designed to show a confirmation dialog to the user before performing a destructive action, such as deleting a file.
๐ŸŒ
Tutorial Republic
tutorialrepublic.com โ€บ snippets โ€บ preview.php
Bootstrap Delete Confirmation Modal Template
ร— Note: See the tutorial on Bootstrap Modals to learn how to customize this layout further.
๐ŸŒ
Blazorise
blazorise.com โ€บ blocks โ€บ applications โ€บ crud โ€บ delete-confirmations
Blazorise Delete Confirm (CRUD) - Blazorise UI components
Ensure the user is prepared to delete a selected item by starting with a collection of delete confirmation modal components based on the CRUD layout.
๐ŸŒ
CodePen
codepen.io โ€บ ungkunazmi โ€บ pen โ€บ NWrLyVb
Alert Delete Confirmation Modal
This process cannot be undone.</p> </div> <div class="modal-footer justify-content-center"> <button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button> <button type="button" class="btn btn-danger">Delete</button> </div> </div> </div> </div> </body> </html> ... body { font-family: 'Varela Round', sans-serif; } .modal-confirm { color: #636363; width: 400px; } .modal-confirm .modal-content { padding: 20px; border-radius: 5px; border: none; text-align: center; font-size: 14px; } .modal-confirm .modal-header { border-bottom: none; position: relative; } .modal-confirm h4 { t
๐ŸŒ
Stack Exchange
ux.stackexchange.com โ€บ questions โ€บ 118515 โ€บ modal-inside-a-modal-delete-confirmation
interaction design - modal inside a modal (delete confirmation) - User Experience Stack Exchange
If the modal is of moderate size, you could simply substitute the current modal by the deletion confirmation modal. In this case, you need to have a message that refers explicitly to the specific item they're going to delete: Delete item ABCD? - Cancel - Confirm, rather than Delete this item?
๐ŸŒ
Dribbble
dribbble.com โ€บ shots โ€บ 21245702-Delete-confirmation-modal
Delete confirmation modal by Flowbite on Dribbble
The purpose of the modal is to prevent accidental deletions by asking the user to confirm their decision before proceeding.
๐ŸŒ
SitePoint
sitepoint.com โ€บ general web dev
Simple Bootstrap 4 Modal Delete Confirm - General Web Dev - SitePoint Forums | Web Development & Design Community
March 25, 2019 - <!doctype html> <html lang="en"> <head> <!-- Required meta tags --> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <!-- Bootstrap CSS --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous"> <title>Delete Confirm</title> </head> <body> <!-- Button trigger modal --> <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal"> DELETE </button> <!-
๐ŸŒ
Codemoto
codemoto.io โ€บ home โ€บ develop a react delete confirmation modal
Codemoto | Develop a React Delete Confirmation Modal - Codemoto
December 30, 2020 - Making sure users donโ€™t accidentally delete data is an important safeguard for most web applications. This React tutorial will show you how to create a reusable delete confirmation modal using React, React Bootstrap, and React Font Awesome. Hereโ€™s a quick overview of the user experience ...
๐ŸŒ
Tutorial Republic
tutorialrepublic.com โ€บ codelab.php
Live Demo: Bootstrap Delete Confirmation Modal
View the live example as well as try and test it using the online HTML editor.
Top answer
1 of 13
429

GET recipe

For this task you can use already available plugins and bootstrap extensions. Or you can make your own confirmation popup with just 3 lines of code. Check it out.

Say we have this links (note data-href instead of href) or buttons that we want to have delete confirmation for:

Copy<a href="#" data-href="delete.php?id=23" data-toggle="modal" data-target="#confirm-delete">Delete record #23</a>

<button class="btn btn-default" data-href="/delete.php?id=54" data-toggle="modal" data-target="#confirm-delete">
    Delete record #54
</button>

Here #confirm-delete points to a modal popup div in your HTML. It should have an "OK" button configured like this:

Copy<div class="modal fade" id="confirm-delete" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                ...
            </div>
            <div class="modal-body">
                ...
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
                <a class="btn btn-danger btn-ok">Delete</a>
            </div>
        </div>
    </div>
</div>

Now you only need this little javascript to make a delete action confirmable:

Copy$('#confirm-delete').on('show.bs.modal', function(e) {
    $(this).find('.btn-ok').attr('href', $(e.relatedTarget).data('href'));
});

So on show.bs.modal event delete button href is set to URL with corresponding record id.

Demo: http://plnkr.co/edit/NePR0BQf3VmKtuMmhVR7?p=preview


POST recipe

I realize that in some cases there might be needed to perform POST or DELETE request rather then GET. It it still pretty simple without too much code. Take a look at the demo below with this approach:

Copy// Bind click to OK button within popup
$('#confirm-delete').on('click', '.btn-ok', function(e) {

  var $modalDiv = $(e.delegateTarget);
  var id = $(this).data('recordId');

  $modalDiv.addClass('loading');
  $.post('/api/record/' + id).then(function() {
     $modalDiv.modal('hide').removeClass('loading');
  });
});

// Bind to modal opening to set necessary data properties to be used to make request
$('#confirm-delete').on('show.bs.modal', function(e) {
  var data = $(e.relatedTarget).data();
  $('.title', this).text(data.recordTitle);
  $('.btn-ok', this).data('recordId', data.recordId);
});

Show code snippet

Copy// Bind click to OK button within popup
$('#confirm-delete').on('click', '.btn-ok', function(e) {

  var $modalDiv = $(e.delegateTarget);
  var id = $(this).data('recordId');

  $modalDiv.addClass('loading');
  setTimeout(function() {
    $modalDiv.modal('hide').removeClass('loading');
  }, 1000);

  // In reality would be something like this
  // $modalDiv.addClass('loading');
  // $.post('/api/record/' + id).then(function() {
  //   $modalDiv.modal('hide').removeClass('loading');
  // });
});

// Bind to modal opening to set necessary data properties to be used to make request
$('#confirm-delete').on('show.bs.modal', function(e) {
  var data = $(e.relatedTarget).data();
  $('.title', this).text(data.recordTitle);
  $('.btn-ok', this).data('recordId', data.recordId);
});
Copy.modal.loading .modal-content:before {
  content: 'Loading...';
  text-align: center;
  line-height: 155px;
  font-size: 20px;
  background: rgba(0, 0, 0, .8);
  position: absolute;
  top: 55px;
  bottom: 0;
  left: 0;
  right: 0;
  color: #EEE;
  z-index: 1000;
}
Copy<script data-require="jquery@*" data-semver="2.0.3" src="//code.jquery.com/jquery-2.0.3.min.js"></script>
<script data-require="bootstrap@*" data-semver="3.1.1" src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
<link data-require="bootstrap-css@3.1.1" data-semver="3.1.1" rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" />

<div class="modal fade" id="confirm-delete" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">ร—</button>
        <h4 class="modal-title" id="myModalLabel">Confirm Delete</h4>
      </div>
      <div class="modal-body">
        <p>You are about to delete <b><i class="title"></i></b> record, this procedure is irreversible.</p>
        <p>Do you want to proceed?</p>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
        <button type="button" class="btn btn-danger btn-ok">Delete</button>
      </div>
    </div>
  </div>
</div>
<a href="#" data-record-id="23" data-record-title="The first one" data-toggle="modal" data-target="#confirm-delete">
        Delete "The first one", #23
    </a>
<br />
<button class="btn btn-default" data-record-id="54" data-record-title="Something cool" data-toggle="modal" data-target="#confirm-delete">
  Delete "Something cool", #54
</button>
Run code snippetEdit code snippet Hide Results Copy to answer Expand

Demo: http://plnkr.co/edit/V4GUuSueuuxiGr4L9LmG?p=preview


Bootstrap 2.3

Here is an original version of the code I made when I was answering this question for Bootstrap 2.3 modal.

Copy$('#modal').on('show', function() {
    var id = $(this).data('id'),
        removeBtn = $(this).find('.danger');
    removeBtn.attr('href', removeBtn.attr('href').replace(/(&|\?)ref=\d*/, '$1ref=' + id));
});

Demo: http://jsfiddle.net/MjmVr/1595/

2 of 13
165

http://bootboxjs.com/ - latest works with Bootstrap 3.0.0

The simplest possible example:

Copybootbox.alert("Hello world!"); 

From the site:

The library exposes three methods designed to mimic their native JavaScript equivalents. Their exact method signatures are flexible as each can take various parameters to customise labels and specify defaults, but they are most commonly called like so:

Copybootbox.alert(message, callback)
bootbox.prompt(message, callback)
bootbox.confirm(message, callback)

Here's a snippet of it in action (click "Run code snippet" below):

Copy$(function() {
  bootbox.alert("Hello world!");
});
Copy<!-- required includes -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" rel="stylesheet"/>

<!-- bootbox.js at 4.4.0 -->
<script src="https://rawgit.com/makeusabrew/bootbox/f3a04a57877cab071738de558581fbc91812dce9/bootbox.js"></script>
Run code snippetEdit code snippet Hide Results Copy to answer Expand