I am working on the two different partial views which is work together.
When using multiple modals on one page open at the same time on top of each other dismissing the topmost with data-dismiss="modal" will hide all active modals,
In my case I'm using a component inside a modal dialog box, that in turn uses modal dialog boxes.
You can find the things in image, 3 different views,
Black in the Background,
Edit (Partial view),
Warning Message(Partial view).
Multiple model open at the same time but need to close the expected, which is topmost/current not all models.
HTML
<div class="modal fade" id="myModal" ng-model="mymodel">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h2 class="modal-title">Are you sure want to Change in Amount?</h2>
</div>
<div class="modal-body">
<p class="text-danger" style="font-size:initial;color:black;font:200">Click save to change the Amount.…</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-inverse" onclick="savedata()">Save</button>
<button type="button" data-dismiss="modal" class="btn btn-inverse">Cancel</button>
</div>
<div class="row-fluid span12">
</div>
</div>
</div>
</div>
modal-header class is used to define the style for the header of the modal. The <button> inside the header has a data-dismiss="modal" attribute which closes the modal if you click on it.
When the Button is clicked, the HTML DIV is referenced using jQuery and its modal function is called along with properties data-backdrop: "static" and data-keyboard: false which disables the closing of the Bootstrap Modal Popup when clicked outside.
Modals are built with HTML, CSS, and JavaScript. They're positioned over everything else in the document and remove scroll from the <body> so that modal content scrolls instead. Clicking on the modal “backdrop” will automatically close the modal.
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. Then click on the backdrop, close icon or close button to close the modal.
Remove data-dismiss="modal"
from the button and Using Jquery you can close a particular modal
.Create a function and have the below code inside the function and call that function on the close button click
$('#modalid').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