title: Adding backbone.js events after initialization
body: <p>This code does not have much context, but will illustrate my question. It's a Backbone view defined in an AMD module which I use to load via require.js</p>
  
  <p>Essentially I want to be able to add events to a Backbone view after initialization has been run. At the moment I am making an empty events object, and then in a method called addView, I add an event each time the function is called. This is not currently working.</p>
  
  <p>I'm not sure at what point the events are registered, but I'm suspecting that I somehow have to get the view to update it's listeners when the <code>events</code> object changes?</p>
  
  <p>Does anybody know how I can achieve adding events to a Backbone.js after initialization?</p>
  
  <pre><code>   define([
      'jQuery',
      'Backbone'],
  
      function ($, Backbone) {
  
          var contentViews = new Array();
  
          var SlidePanelView = Backbone.View.extend({
  
              events: {},
  
              /// &lt;param name="targetDataAtt"&gt;The unique value inside the target's Data-Slide-Panel-Id attribute&lt;/param&gt;  
              /// &lt;param name="event"&gt;Backbone event to trigger view&lt;/param&gt;
              /// &lt;param name="destroyOnRemove"&gt;True to destroy view when removed, False otherwise (Default true)&lt;/param&gt;  
              addView: function (targetDataAtt, event, view, destroyOnRemove) {
                  destroyOnRemove = typeof destroyOnRemove !== 'undefined' ? destroyOnRemove : true;
  
                  this.events[event] = "viewEventFired";
                  contentViews[targetDataAtt] = { View: view, DestroyOnRemove: destroyOnRemove };
              },
  
              viewEventFired: function (e) {
  
                  var target = $(e.target);
                  var id = target.attr('data-slide-panel-id');
                  console.log(id);
              }
  
          });
  
          // Return a singleton??
          return new SlidePanelView;
  
  
      });
  </code></pre>