dfsq's answer is very nice. I modified it a bit to fit my needs: I actually needed a modal for the case that, after clicking, the user would also be navigated to the corresponding page. Executing the query asynchronously is not always what one needs.

Using Blade I created the file resources/views/includes/confirmation_modal.blade.php:

<div class="modal fade" id="confirmation-modal" tabindex="-1" role="dialog" aria-labelledby="confirmation-modal-label" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <h4>{{ $headerText }}</h4> </div> <div class="modal-body"> {{ $bodyText }} </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button> <form action="" method="POST" style="display:inline"> {{ method_field($verb) }} {{ csrf_field() }} <input type="submit" class="btn btn-danger btn-ok" value="{{ $confirmButtonText }}" /> </form> </div> </div> </div> </div> <script> $('#confirmation-modal').on('show.bs.modal', function(e) { href = $(e.relatedTarget).data('href'); // change href of button to corresponding target $(this).find('form').attr('action', href); }); </script>

Now, using it is straight-forward:

<a data-href="{{ route('data.destroy', ['id' => $data->id]) }}" data-toggle="modal" data-target="#confirmation-modal" class="btn btn-sm btn-danger">Remove</a>

Not much changed here and the modal can be included like this:

@include('includes.confirmation_modal', ['headerText' => 'Delete Data?', 'bodyText' => 'Do you really want to delete these data? This operation is irreversible.', 'confirmButtonText' => 'Remove Data', 'verb' => 'DELETE'])

Just by putting the verb in there, it uses it. This way, CSRF is also utilized.

Helped me, maybe it helps someone else.



Related news

Martirio sevillanas de los bloques karaoke music
Que significa hacer el tacto
Swany moda feminina
Que es correcto verter o vertir concreto
Eq frequencies for different instruments and their sounds
Robiquette saint gregoire quebec
Para que sirve la ruda con romero
Etat suicidaire que faire a shanghai
Edwards pharmacy empangeni accommodation