Delete warning

Posted 9 months ago by MrLukman

hey guys i wanna ask how to display a delete warning with sweet alert

here's my blade

 <form id="inbox" action ="{{ action('[email protected]', $inbox->id) }}" method="post">

                    {{csrf_field()}}
                    <input name = "_method" type="hidden" value="DELETE"/>
                    <button id ="delete" type = "submit" class = "btn btn-danger btn-xs" value= "Delete"/>
                      
                    </button>


<script>
 $('button.btn btn-danger btn-xs').on('click', function()
{

  // Display SweetAlert

   swal("Are you sure?", {
  icon: "warning",
  dangerMode: true,
  buttons: true,
}),

 //On clicking 'Yes, I am sure to delete'

 function(){  
      $(this).closest('#inbox').submit();
    }

}
   
</script>

the problem is when i press the delete button the item just deleted right away. thanks for the help

Please sign in or create an account to participate in this conversation.

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up

Channels

Reply to

Use Markdown with GitHub-flavored code blocks.