Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bootstrap modal disappear immediately after showing

I'm using bootstrap's modal plugin in rails

The website says I can gain the function without write javascript.

I add the following line in my HTML(in slim):

div#makeDream.modal.hide.fade      div.modal-header         a.close data-dismiss='modal'         h3 Hello World!                 div.modal-body     div.modal-footer  a data-toggle='modal' data-target='#makeDream' Button 

However, after I clicking the Button. the modal shows up, but immediately disappears!

I found the css of #makeDream has

display:none 

I don't where it comes

Can someone tell me how to fix it?

like image 590
HanXu Avatar asked Mar 27 '12 05:03

HanXu


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?

You can prevent closing of modal dialog by setting the beforeClose event argument cancel value to true. In the following sample, the dialog is closed when you enter the username value with minimum 4 characters.

How do I stop bootstrap modal from hiding when clicking 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.

How do I keep modal open after submitting?

Show activity on this post. and write your html code in update panel then remove data-dismiss="modal" from the button. Hope it works for you. It would be great if you could add some explanation to your code.


1 Answers

I had this problem and the solution was simple... I was loading both bootstrap.js AND bootstrap-modal.js.

bootstrap.js includes bootstrap-modal.js.

Solution: Remove bootstrap-modal.js from your head and it'll work correctly.

like image 158
Adam Avatar answered Sep 22 '22 13:09

Adam