Confirmation before deleting an item

Submitted by ismaeltoe - 2 years ago

When user clicks on "delete" button, open a confirmation box before deleting an item.

@foreach (items as item)
    <form class="delete" action="{{ route('item.destroy', $item->id) }}" method="POST">
        <input type="hidden" name="_method" value="DELETE">
        <input type="hidden" name="_token" value="{{ csrf_token() }}" />
        <input type="submit" value="Delete">

    $(".delete").on("submit", function(){
        return confirm("Do you want to delete this item?");
comments powered by Disqus

Ads cover the costs of maintaining Laravel-tricks