my work is using javascript bootstrap 2.0.4
I'm looking for a way to cancel the modal from closing, by logic control. but I can't find any details how to do this
http://getbootstrap.com/javascript/#modals
something like .NET
OnWindowClosing(eventArguement) { if (shouldCancel) { eventArguement.Cancel = true; return; } }
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.
Data-keyword="false" is to prevent closing modal while clicking Esc button, while data-backdrop="static" , allows you keep modal pop-up opened when clicking on Gray area.
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.
// We use data-dismiss property of modal-up in html to close the modal-up,such as <div class='modal-footer'><button type='button' class="btn btn-default" data-dismiss='modal'>Close</button></div> // We can close the modal pop-up through java script, such as <div class='modal fade pageModal' id='openModal' tabindex='-1' ...
Look at here : www.bootply.com/QTTDf3zRgV
In this exemple, if the checkbox is checked, then the modal can't be closed ( with js/jquery):
$('#myModal').on('hide.bs.modal', function(e){ if( $('#block').is(':checked') ) { e.preventDefault(); e.stopImmediatePropagation(); return false; } });
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