title: Extending bootstrap jQuery modal
body: <p>I would like to extend <code>$.fn.modal</code> in Bootstrap/jQuery so my extended version "does things" before a modal is initialized by passing extra options. I tried this like I do some times to extend jQuery prototypes:</p>
  
  <pre><code>var modal = $.fn.modal;
  
  $.fn.modal = function() {
      this.each(function() {
          // do stuff
      });
      modal.apply(this, arguments);
  }
  
  $('#modal').modal(); // fails
  </code></pre>
  
  <p>The example above does not work, although the same pattern works for many other non-bootstrap jQuery prototypes.</p>
  
  <p>Here’s a fiddle that demonstrates it: <a href="http://jsfiddle.net/eTWSb/" rel="nofollow">http://jsfiddle.net/eTWSb/</a> (just comment the override stuff to see it working).</p>
  
  <p>I was under the impression that cloning a function and then calling it as a "super" is a viable option when you want to add custom functionality. </p>
  
  <p>Any suggestions?</p>