BBOOOOTTSSTTRRAAPP MMOODDAALL PPLLUUGGIINN http://www.tutorialspoint.com/bootstrap/bootstrap_modal_plugin.htm Copyright © tutorialspoint.com

A modal is a child that is layered over its parent window. Typically, the purpose is to display content from a separate source that can have some interaction without leaving the parent window. Child windows can provide information, interaction, or more.

If you want to include this plugin functionality individually, then you will need modal.js. Else, as mentioned in the chapter Bootstrap Plugins Overview, you can include bootstrap.js or the minified bootstrap.min.js.

Usage

You can toggle the modal plugin's hidden content:

Via data attributes : Set attribute data-toggle="modal" on a controller element, like a or link, along with a data-target="#identifier" or href="#identifier" to target a specific modal withthe to toggle.

Via JavaScript : Using this technique you can call a modal with with a single line of JavaScript:

$('#identifier').modal(options)

Example

A static example is shown in the following example:

Example of creating Modals with Twitter Bootstrap

Details of the preceding code:

To invoke the modal window, you need to have some kind of a trigger. You can use a button or a link. Here we have used a button.

If you look in the code above, you will see that in the

Just click the Esc button and the modal window exits. Events

Following table lists the events to work with modal. These events may be used to hook into the function.

Event Description Example

show.bs.modal Fired after the show method is $('#identifier').on('show.bs.modal', called. function () { // do something… })

shown.bs.modal Fired when the modal has been $('#identifier').on('shown.bs.modal', made visible to the user function () { willwaitforCSStransitionstocomplete. // do something… })

hide.bs.modal Fired when the hide instance $('#identifier').on('hide.bs.modal', method has been called. function () { // do something… })

hidden.bs.modal Fired when the modal has $('#identifier').on('hidden.bs.modal', finished being hidden from the function () { user. // do something… }) Example

The following example demonstrates the usage of events:

Example of using events of Modal Plugin

As seen in the above screen, if you click on the Close button i.e hide event, an alert message is displayed. Loading [MathJax]/jax/output/HTML-CSS/jax.js