title: Trigger function on click if View has a certain class (backbone.js)
body: <p>I have a <code>div</code> generated by a backbone.js view. When the user clicks on this <code>div</code>, a class <code>active</code> is added to the <code>div</code> and the function <code>addToSet</code> is executed.</p>
  
  <p><strong>Problem:</strong> I want another function to be triggered when the View's <code>div</code> has the class <code>active</code>. However, my attempt shown below always cause <code>addToSet</code> function to run when its clicked. </p>
  
  <p>Now, I remove <code>'click': 'addToSet'</code> from the <code>events</code> function, leaving only <code>'click .active': 'removeFromSet'</code>. Clicking on the <code>div</code> does not cause anything to happen! Is this because the event handler cannot select the <code>div</code> of the view itself, just the elements inside it?</p>
  
  <p>Any idea how I can solve this problem? Thanks!</p>
  
  <p><strong>JS Code</strong></p>
  
  <pre><code>SetView = Backbone.View.extend({
      tagName: 'div',
      className: 'modal_addit_set',
  
      template: _.template( $('#tpl_modal_addit_set').html() ),
  
      events: {
          'click': 'addToSet',
          'click .active': 'removeFromSet'
      },
  
      initialize: function(opts) {
          this.post_id = opts.post_id;
      },
  
      render: function() {
          $(this.el).html( this.template( this.model.toJSON() ) );
          if(this.model.get('already_added'))
              $(this.el).addClass('active');
          return this;
      },
  
      addToSet: function() {
          $.post('api/add_to_set', {
              post_id: this.post_id,
              set_id: this.model.get('id'),
              user_id: $('#user_id').val()
          });
      },
  
      removeFromSet: function() {
          $.post('api/remove_from_set', {
              post_id: this.post_id,
              set_id: this.model.get('id')
          });
      }
  });
  </code></pre>