user984621
user984621

Reputation: 48493

Bootstrap.js - how to automatically display a modal window?

I like the Bootstrap library by Twitter and I would like to try to use into it in my simple page. I need there after loading the page automatically display the modal window. Could anyone give me a tip, how is possible to do it?

Upvotes: 8

Views: 17177

Answers (3)

Costanzo Pablo
Costanzo Pablo

Reputation: 51

Your modal...

<div class="modal fade" id="formSaludo" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">

If ulike modal opened... Use style="display: block;" and class="modal fade in"

<div class="modal fade in" id="formSaludo" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: block;">

Upvotes: 4

Tabares
Tabares

Reputation: 4335

This modal load when the page is ready.

<body>
    <div id="top"> 
       <a tabindex="-1" href="#" id="metadata-link" data-target="#modal" data-toggle="modal">Metadata</a>
    </div>

   <div id="modal" class="modal hide fade in" style="display:none;">
      <div class="modal-header">header<a class="close" data-dismiss="modal">x</a></div>
      <div class="modal-body"></div>
      <div class="modal-footer">footer</div>
   </div>

<script>

    $(document).ready(function() {
        $('#top').find('a').trigger('click');

    });
</script>

Best regards.

Upvotes: 2

giorgio
giorgio

Reputation: 10212

well that shouldn't be too hard... do something like this:

jQuery(document).ready(function($) {
    $('#my-modal').modal(options)
});

Upvotes: 9

Related Questions