title: Passing context with bind in backbone.js
body: <p>I want my panels to re-render themselves when they are clicked. </p>
  
  <p>However, when I perform a click I get the following:</p>
  
  <pre><code>Uncaught TypeError: Cannot call method 'get' of undefined
  </code></pre>
  
  <p>It appears that the "this" that I'm logging is in fact the model itself:</p>
  
  <pre><code>_callbacks: Object
  _changed: true
  _escapedAttributes: Object
  _previousAttributes: Object
  attributes: Object
  cid: "c0"
  collection: r.d
  id: "f5589ba4-a0aa-dd86-9697-30e532e0f975"
  __proto__: n
  </code></pre>
  
  <p>I'm having trouble figuring out why the appropriate "this" isn't preserved by passing my context into model.bind.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>// Models
  window.Panel = Backbone.Model.extend({
  
      defaults: function(){
          return {
              flipped: false,
          };
      },
  
      toggle: function(){
          this.save({flipped: !this.get("flipped")});
      },
  
  });
  
  
  // Collections
  
  window.PanelList = Backbone.Collection.extend({
  
      model:Panel,
  
      localStorage: new Store("panels"),    
  
      flipped: function(){
          return this.filter(function(panel){ return panel.get("flipped"); })
      }   
  });
  
  
  // Global collection of Panels
  window.Panels = new PanelList;
  
  // Panel View
  
  window.PanelView = Backbone.View.extend({ 
  
      tagName: 'div',
  
      template: _.template($("#panel-template").html()),  
  
      events: {
          "click" : "toggle"
      },
  
      initialize: function(){
          this.model.bind("change", this.render, this) 
          $(this.el).html(this.template(this.model.toJSON()));
      },     
  
      render: function(){    
          console.log(this);
          var flipped = this.model.get("flipped")
          if (flipped){
             $(this.el).addClass("flip"); 
          } else{
             $(this.el).removeClass("flip"); 
          }           
          return this   
      },
  
      toggle: function(){
          this.model.toggle(); 
      }
  });   
  </code></pre>