I use the modal of Twitter's Bootstrap.
You can close the modal, by clicking on a button or something different with the tag data-dismiss="modal"
.
I would like to process my form in the modal with AJAX (by clicking on a submit button) and then close the modal.
So how do close this modal in AJAX?
Or is that not possible?
(sorry for my bad English...)
To close bootstrap modal you can pass 'hide' as option to modal method as follows. $('#CompanyProfile'). modal('hide'); Use this code inside ajax success.
Clicking on the modal “backdrop” will automatically close the modal. Bootstrap only supports one modal window at a time.
There are few ways to close modal in Bootstrap: click on a backdrop, close icon, or close button. You can also use JavaScript hide method. Click the button to launch the modal.
To close a modal, add the w3-button class to an element together with an onclick attribute that points to the id of the modal (id01). You can also close it by clicking outside of the modal (see example below).
If you read further down the documentation:
$('#myModal').modal('hide')
Just get the ID of the modal, and replace myModal
with it. Then place it in the AJAX success handler and there you have it.
You can use this script to close the modal
<button type="button" id="close_btn" class="close" data-dismiss="modal" aria-hidden="true">
<i class = "icons-office-52"></i>
</button>
$("#close_btn").trigger("click");
or
$('#my_model').modal('hide');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With