title: Dynamically listen for Backbone.js view's render function to be called
body: <p>I am trying to dynamically extend Backbone.js view's render function. In doing so, I want to be able to fire an event before and after render is being called. I have tried overwriting the function and call the old function, which works, but all models that bind to the render function lose their bindings. The code that I currently have is the following, were I pass in a created Backbone.js view:</p>
  
  <pre><code>function bindRenders(view) {
  
      view.render = (function() {
          var cachedRender = view.render;
  
          return function() {
              console.log("before render");
              cachedRender.apply(this, arguments);
              console.log("after render");
          };
      }());
  }
  </code></pre>
  
  <p>Again, the above code will work, but all models that are bound to the render function by:</p>
  
  <pre><code>    this.model.on('change', this.render, this);
  </code></pre>
  
  <p>break. The only solution I have found is to rebind the .on('change') event of the model after I overwrite the function. However, not every view's model will be bound in this fashion. Any help is very much appreciated! Thanks!</p>