Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Note</strong>: This solution is targeting <a href="http://getbootstrap.com/2.3.2/javascript.html#modals" rel="nofollow noreferrer">twitter bootstrap 2.x</a>! See <a href="https://stackoverflow.com/a/20183890/1407478">this answer</a> (just below) for differences according to bootstrap 3.</p> <hr> <p>Extending bootstrap modal functionality <em>without</em> modifying original source. </p> <p>Thanks to @David and his suggestion at <a href="https://stackoverflow.com/questions/9137311/how-to-extend-twitter-bootstrap-plugin/12689534#12689534">How to Extend Twitter Bootstrap Plugin</a> I finally got it to work. It is a slightly modified version of his solution with modal "lock" added. I post it as a additional answer since I think it may could be a starting point for others that like me have struggled hard with this issue. </p> <pre class="lang-js prettyprint-override"><code>// save the original function object var _superModal = $.fn.modal; // add locked as a new option $.extend( _superModal.defaults, { locked: false }); // create a new constructor var Modal = function(element, options) { _superModal.Constructor.apply( this, arguments ) } // extend prototype and add a super function Modal.prototype = $.extend({}, _superModal.Constructor.prototype, { constructor: Modal , _super: function() { var args = $.makeArray(arguments) // call bootstrap core _superModal.Constructor.prototype[args.shift()].apply(this, args) } , lock : function() { this.options.locked = true } , unlock : function() { this.options.locked = false } , hide: function() { if (this.options.locked) return this._super('hide') } }); // override the old initialization with the new constructor $.fn.modal = $.extend(function(option) { var args = $.makeArray(arguments), option = args.shift() // this is executed everytime element.modal() is called return this.each(function() { var $this = $(this) var data = $this.data('modal'), options = $.extend({}, _superModal.defaults, $this.data(), typeof option == 'object' &amp;&amp; option) if (!data) { $this.data('modal', (data = new Modal(this, options))) } if (typeof option == 'string') { data[option].apply( data, args ) } }); }, $.fn.modal); </code></pre> <p>With this technique it should not be nessecary to alter bootstrap.js, and the same functionality can more easily be shared among bootstrap projects. This method should be applicable to all the other bootstrap plugins. Have so far only tried with button though, but I cant se why it shouldnt. </p> <p>see working fiddle -> <strong><a href="http://jsfiddle.net/Sz7ZS/" rel="nofollow noreferrer">http://jsfiddle.net/Sz7ZS/</a></strong></p>
    singulars
    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. 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