Reputation: 659
I have this Jquery code:
<script type="text/javascript">
$('.blog-form').submit(function (e) {
e.preventDefault();
var blog_form = $(this);
bootbox.confirm("Are you sure?", function (result) {
if (result) {
blog_form.submit();
}
});
});
</script>
And in my Laravel Form:
{!! Form::open(['action' => ['Test\\TestController@destroy', $thread->id], 'method' => 'delete', 'class' => 'blog-form']) !!}
{!! Form::submit('Delete', ['class' => 'btn btn-danger']) !!}
{!! Form::close() !!}
If I'm pressing the submit button, the confirm-message will appear. If I'm pressing on 'cancle', the confirmation of course disappear. so.. If I'm pressing the 'Ok' button, then the confirm message will fade out but at the same time a knew confirmation-message pops out. over and over again. So I can't press Ok, without getting another confirm-message. I wasn't able to solve this problem yet. Thanks for any help :)
Upvotes: 0
Views: 385
Reputation: 1348
The problem is that you are calling the same submit()
function, which you intercept in jQuery. One way to prevent this, is by using a flag.
<script type="text/javascript">
var confirmed = false;
$('.blog-form').submit(function (e) {
if(confirmed){
return;
}
e.preventDefault();
var blog_form = $(this);
bootbox.confirm("Are you sure?", function (result) {
if (result) {
confirmed = true;
blog_form.submit();
}
});
});
</script>
Upvotes: 1