I'm trying to create delete confirmation in my app using sweetalert, here is what I've done so far..
View :
<div class="box-button">
{!! Form::open(['method' => 'POST', 'class' => 'deleteedition', 'action' => ['EditionController@destroy', $edition->id]]) !!}
<input type="hidden" name="_method" value="DELETE">
<input type="hidden" name="_token" value="" />
{!! Form::submit('Delete', ['class' => 'btn btn-danger btn-sm', 'id'=>'deleteedition1']) !!}
{!! Form::close() !!}
</div>
JS :
<script>
$("#deleteedition1").on("click", function () {
swal({
title: "Are you sure?",
text: "You will not be able to recover this lorem ipsum!", type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, delete it!",
closeOnConfirm: false
},
function () {
$(".deleteedition").submit();
});
});
</script>
The problem is when I click the delete button it will keep deleting the file even thought I haven't confirm it. Can someone please tell me what I did wrong ? Thanks for the help!
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2gCddwc
via IFTTT
Aucun commentaire:
Enregistrer un commentaire