Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Thanks @davidkonrad for your work on this. I was trying to implement this as well and it seems that things have changed with bootstrap 3. Now instead of: </p> <p><code>_superModal.defaults</code> </p> <p>it is now attached to the constructor so you have to do </p> <p><code>_superModal.Constructor.DEFAULTS</code></p> <p>Also the constructor has changed which meant that I had to copy it and modify it which is less than ideal. Instead I've come up with the following code that works and does not copy the constructor and should be more fool-proof if bootstrap changes going forward. Have a go:</p> <pre><code>// save the original function object var _superModal = $.fn.modal; // add locked as a new option $.extend( _superModal.Constructor.DEFAULTS, { locked: false }); // capture the original hide var _hide = _superModal.Constructor.prototype.hide; // console.log('HIDE:', _hide); // add the lock, unlock and override the hide of modal $.extend(_superModal.Constructor.prototype, { // locks the dialog so that it cannot be hidden lock: function() { // console.log('lock called'); // console.log('OPTIONS',this.options); this.options.locked = true; } // unlocks the dialog so that it can be hidden by 'esc' or clicking on the backdrop (if not static) ,unlock: function() { // console.log('unlock called'); this.options.locked = false; } // override the original hide so that the original is only called if the modal is unlocked ,hide: function() { // console.log('hide called'); if (this.options.locked) return; _hide.apply(this, arguments); } }); </code></pre> <p>So in order to lock the modal:</p> <p><code>$('#dlg').modal('lock');</code></p> <p>and to unlock:</p> <p><code>$('#dlg').modal('unlock');</code></p> <p>Yay!</p>
 

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