Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery/Bootstrap - Twitter Bootstrap Modal Opening On Page Load?

I am using Twitter Bootstrap's Modal plugin, it all is working, and console is showing no javascript errors, but my issue is that its opening when the page loads? I close the modal, then can re open it no problem, but it just keeps opening when ever I reload the page. Here is my markup

HTML Launch modal

<div id="myModal" class="modal hide fade" 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">Modal header</h3>
</div>

   <div class="modal-body">
     <p>One fine body…</p>
   </div>

  <div class="modal-footer">
    <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
     <button class="btn btn-primary">Save changes</button>
   </div>
  </div>

Javascript

Pretty simple really :P,

 <script>
 $('#myModal').modal()  
 </script>
like image 918
Necro. Avatar asked Dec 03 '25 17:12

Necro.


1 Answers

$('#myModal').modal('hide') 

try this

http://twitter.github.com/bootstrap/javascript.html#modals

like image 116
mpm Avatar answered Dec 06 '25 06:12

mpm



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!