Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You are not the only one who are missing that feature. I think bootstrap sometimes is too "minimalistic", the people behind has the idea a lot should be done in the "implementation layer", but it is to no use when the bootstrap jQuery plugins themselves makes it impossible!</p> <p><strong>You have to implement the functionality yourself, like this</strong> :</p> <p>in <code>bootstrap.js</code> v2.1.1 modal begins at line 61. </p> <p>in <code>Modal.prototype</code>, add two functions, <code>lock</code> and <code>unlock</code>, so it looks like this (I show here only the beginning of <code>modal.prototype</code>, becuase it is too much code)</p> <pre><code> Modal.prototype = { constructor: Modal //add this function , lock: function () { this.options.locked = true } //add this function , unlock: function () { this.options.locked = false } , toggle: function () { ... ... </code></pre> <p>Then, also in Modal.prototype, find the function <code>hide</code>, and add a line so it looks like this (again, only top of hide is showed)</p> <pre><code>, hide: function (e) { e &amp;&amp; e.preventDefault() var that = this //add this line if (that.options.locked) return e = $.Event('hide') ... ... </code></pre> <p>And finally, alter <code>$.fn.modal.defaults</code> to :</p> <pre><code> $.fn.modal.defaults = { backdrop: true , keyboard: true , show: true , locked: false //this line is added } </code></pre> <p>Now you have on-the-fly lock/unlock functionality in your bootstrap modal, preventing the user from closing the modal at critical moments. </p> <p><strong>Example</strong> :</p> <p>This is an altered version of "Live Demo" from <a href="http://twitter.github.com/bootstrap/javascript.html#modals" rel="nofollow">http://twitter.github.com/bootstrap/javascript.html#modals</a></p> <pre><code>&lt;!-- Button to trigger modal --&gt; &lt;a href="#myModal" role="button" class="btn" data-toggle="modal"&gt;Launch demo modal&lt;/a&gt; &lt;!-- Modal --&gt; &lt;div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"&gt; &lt;div class="modal-header"&gt; &lt;button type="button" class="close" data-dismiss="modal" aria-hidden="true"&gt;×&lt;/button&gt; &lt;h3 id="myModalLabel"&gt;Modal header&lt;/h3&gt; &lt;/div&gt; &lt;div class="modal-body"&gt; &lt;p&gt;One fine body…&lt;/p&gt; &lt;/div&gt; &lt;div class="modal-footer"&gt; &lt;button class="btn" data-dismiss="modal" aria-hidden="true"&gt;Close&lt;/button&gt; &lt;button class="btn btn-primary" onclick="$('#myModal').modal('lock');"&gt;lock&lt;/button&gt; &lt;button class="btn btn-primary" onclick="$('#myModal').modal('unlock');"&gt;unLock&lt;/button&gt; &lt;/div&gt; &lt;/div&gt; &lt;script type="text/javascript"&gt; </code></pre> <p>I have inserted two buttons, "lock" and "unlock" - when clicked, they set the modal in either locked or normal mode (the settings it is initialised with)</p> <p><strong>Edit</strong>, in your case, you just have to call lock/onlock when doing ajax :</p> <pre><code>$("myModal").modal('lock'); $.ajax({ url: url, ... ... , success(html) { ... ... $("#myModal").modal('unlock'); } }); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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