title: Routing & events - backboneJS
body: <p>How should I be handling routing in BackboneJS? When routing, after new-upping my view, should I be triggering an event, or rendering the view directly? </p>
  
  <p>Here are the two scenarios: </p>
  
  <p>Trigger Event: </p>
  
  <pre><code>routes: {
      'orders/view/:orderId' : 'viewOrder'
  },
  viewOrder: function (orderId) {
      var viewOrderView = new ViewOrderView();
      vent.trigger('order:show', orderId);
  }
  </code></pre>
  
  <p>In my view, I have: </p>
  
  <pre><code>var ViewOrderView = Backbone.View.extend({
      el: "#page",
      initialize: function () {
          vent.on('order:show', this.show, this);
      },
      show: function (id) {
          this.id = id;
          this.render();
      },
      render: function () {
          var template = viewOrderTemplate({ id: this.id });
          this.$el.html(template);
          return this;
      }
  });
  </code></pre>
  
  <p>OR, should I go this route: </p>
  
  <pre><code>routes: {
      'orders/view/:orderId' : 'viewOrder'
  },
  viewOrder: function (orderId) {
      var viewOrderView = new ViewOrderView({id : orderId });
      viewOrderView.render();
  }
  </code></pre>
  
  <p>In my view, I have: </p>
  
  <pre><code>var ViewOrderView = Backbone.View.extend({
      el: "#page",
      initialize: function () {
          //init code here
      },
      render: function () {
          var template = viewOrderTemplate({ id : this.id});
          this.$el.html(template);
          return this;
      }
  });
  </code></pre>
  
  <p>I <strong>think</strong> it's the first scenario - given that backbone is event driven, but the 2nd obviously has less code. </p>
  
  <p>Also, I suppose a third scenario would be to keep the view code in the first scenario, but grab the router scenario of the second... rendering the view on navigation, but exposing an event in case I want to trigger that elsewhere.</p>
  
  <p>Thoughts?</p>