I'm working on a website using bootstrap.
Basically, I wanted to use a modal in the home page, summoned by the button in the Hero Unit.
Button code:
<button type="button"
class="btn btn-warning btn-large"
data-toggle="modal"
data-target="#myModal">Open Modal</button>
Modal code:
<div class="modal hide fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel">In Costruzione</h3>
</div>
<div class="modal-body">
<p>Test Modal: Bootstrap</p>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Chiudi</button>
<button class="btn btn-warning">Salva</button>
</div>
</div>
The problem is that as soon as I click on the button, the modal fades in and then immediately disappears.
I'd appreciate any help.
Also, how to change the dropdown triangle's color (pointing up, no hover)? I'm working on a website based on orange and brown and that blue thing is really annoying.
Same symptom, in the context of a Rails application with Bootstrap provided by the
bootstrap-sass
gem, and @merv's answer put me on the right track.My
application.js
file had the following:The fix was to remove one of the two lines. Indeed, the gem's readme warns you about this error. My bad.
My code somehow had the bootstrap.min.js included twice. I removed one of them and everything works fine now.
in case anyone using codeigniter 3 bootstrap with datatable.
below is my fix in config/ci_boostrap.php
while working with Angular(5) , i face the same issue , but in my case i solved as follows:
component.html
component.ts
NOTE: need to import jquery in ts file as "declare var $ :any;"
Changes i made :
removed "data-toggle="modal" from Button tag (thanks to @miCRoSCoPiC_eaRthLinG this answer helps me here) in my case its showing modal so i created (click)="showresult()"
inside component.ts need to declare Jquery($) and inside button click method showresult() call " $('#myModal').modal('show');"
In my case I have use
actionlink
button in MVC and I have facing this issue, I have tried many solutions above and other, but still facing that issue, then I realize my error in code.I have called modal in javascript by using
Before the error I using this button
I have no value for href property in this button so I facing the issue.
Then I edit this button code like this
then issue get solved just an error because of no # in first one.
see if this will helpful to you.
I too had the issue, if the button is inside a tag then the modal appears once and disappears soon enough, taking the button out of the form fixed the isue. Thanks I ended up in this thread! +1 to all.