title: Changing the scope of 'this' using bind prototype
body: <p>I am using bind to change the scope of 'this' so that I am able to reference  my generateContent function using 'this', from within my click function. Unfortunately this means that this.id no longer works as the scope of 'this' has changed.</p>
  
  <p>What is the best way to grab the id of the clicked button, in this case:</p>
  
  <pre><code>function help( doc ) {
  
      buttons: function() {
  
          $('.add-btn').click( function() {
  
          this.generateContent( this.id ) );
  
          }.bind(this));
  
      },
  
      generateContent: function ( id ){
  
      }
  
  }
  
  // This function binds a function to an object's scope.
  Function.prototype.bind = function(scope) {
      var _function = this;
      return function() {
          return _function.apply(scope, arguments);
      }
  }
  </code></pre>