Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy is Bootstraps "Modal" Plugin callback not firing?
    text
    copied!<p>I'm having a problem understanding Bootstraps Modal <strong>Callbacks</strong>.</p> <p>The "<em>.on('show',function(){})</em>" portion of the following code is not firing. Not sure why. Please advise. Also, any/all code optimization tips welcome.</p> <p><strong>The HTML</strong></p> <pre><code>&lt;p&gt;&lt;a class="bsModal" href="#" title="Bootstrap Modal"&gt;testing modal&lt;/a&gt;&lt;/p&gt; </code></pre> <p><strong>The jQuery</strong></p> <pre><code> // Dynamically calling Bootstrap Modal $('.bsModal').click(function(){ var bsModalWindow = '&lt;div class="modal" id="myModal"&gt;'; bsModalWindow += '&lt;div class="modal-header"&gt;'; bsModalWindow += '&lt;button type="button" class="close" data-dismiss="modal"&gt;×&lt;/button&gt;'; bsModalWindow += '&lt;h3&gt;Modal header&lt;/h3&gt;'; bsModalWindow += '&lt;/div&gt;'; bsModalWindow += '&lt;div class="modal-body"&gt;'; bsModalWindow += '&lt;p&gt;This is an example of the Bootstrap jQuery Plugin: Modal.&lt;/p&gt;'; bsModalWindow += '&lt;/div&gt;'; bsModalWindow += '&lt;div class="modal-footer"&gt;'; bsModalWindow += '&lt;a href="#" class="btn" data-dismiss="modal"&gt;Close&lt;/a&gt;'; bsModalWindow += '&lt;a href="#" class="btn btn-primary"&gt;Save changes&lt;/a&gt;'; bsModalWindow += '&lt;/div&gt;'; bsModalWindow += '&lt;/div&gt;'; $(bsModalWindow).modal() .on('show', function() { console.log('Modal will be shown'); }) .on('shown', function() { console.log('Modal was shown'); }) .on('hide', function() { console.log('Modal will be hidden'); }) .on('hidden', function() { console.log('Modal is hidden'); }) .show({ backdrop: true, keyboard:true }); }); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload