Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

javascript bootstrap modal - cancel closing

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;     } } 
like image 559
Kelmen Avatar asked Jan 20 '14 08:01

Kelmen


People also ask

How do I stop a bootstrap modal from closing?

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.

How do you stop a modal closing?

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.

How do I stop bootstrap modal popup?

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.

How do I stop the modal pop-up in HTML?

// 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' ...


1 Answers

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;     } }); 
like image 169
BENARD Patrick Avatar answered Oct 11 '22 02:10

BENARD Patrick