Lets discuss how to create modal dialog box using twitter bootstrap. You need to include bootstrap.css
and bootstrap.js file in your page where you want to display the dialog box.
Click here to
learn detail about bootstrap and download the required files.
<a data-toggle="modal" href="#myModal" class="btn btn-primary btn-large"> Launch demo modal</a>
<div class="modal" id="myModal"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true"> ×</button> <h4 class="modal-title">Modal Title Goes Here</h4> </div> <div class="modal-body">....</div> <div class="modal-footer"> <a href="#" class="btn btn-default" data-dismiss="modal">Close</a> <a href="#" class="btn btn-primary">Do Nothing</a> </div> </div><!-- /.modal-content --> </div><!-- /.modal-dialog --> </div>
href
and assign the modal box id to data-target
.<a data-toggle="modal" href="external.html" data-target="#modal" class="btn btn-primary btn-large">Load External Page</a>
<div class="modal" id="modal"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true"> ×</button> <h4 class="modal-title">Modal Title Goes Here</h4> </div> <div class="modal-body"> Load Data... </div> <div class="modal-footer"> <a href="#" class="btn btn-default" data-dismiss="modal">Close</a> <a href="#" class="btn btn-primary">Do Nothing</a> </div> </div><!-- /.modal-content --> </div><!-- /.modal-dialog --> </div>
Name | Type | Default | Description |
data-backdrop | boolean | true | used to include a modal-backdrop element |
data-keyboard | boolean | true | Closes the modal when escape key is pressed |
data-show | boolean | true | Shows the modal when load. |
data-remote | path | false | Load external page. |
$('#myModal').modal({ keyboard: false })
$('#myModal').modal('toggle')
$('#myModal').modal('show')
$('#myModal').modal('hide')