How to continue to submit a form after preventing it with jQuery?
For Example:
There is a deleting input
element:
<form action="/articles/{{ $article->id }}" method="POST">
{{ method_field('DELETE') }}
{{ csrf_field() }}
<input class="btn btn-danger btn-sm need-alert" type="submit" value="delete">
</form>
I want to give users a sweetalert2
alert before submitting the form.
Javascript code:
<script>
$('.need-alert').on('click', function (event) {
event.preventDefault();
//sweetalert2 code
swal({
title: 'Are you sure?',
text: "You won't be able to revert this!",
type: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Yes, delete it!'
}).then(function () {
//...
}).catch(swal.noop);
})
</script>
The sweetalert2
alert box could be shown correctly.
Question:
How to continue to submit the form after clicking sweetalert2 alert box's confirm button?