title: Backbone + Rails collection fetching
body: <p>Previously, my Backbone router looked like this:</p>
  
  <pre><code>class App.Routers.ThingsRouter extends Backbone.Router
    routes: '': 'index'
    routes: 'previews/:id': 'show'
  
    initialize: -&gt;
      @collection = new App.Collections.ThingsCollection
      @collection.fetch
  
    index: -&gt;
      view = new App.Views.ThingsIndex(collection: @collection)
      $('#app-container').html(view.render().el)
  
    show: (id) -&gt;
      @model = @collection.get(id)
      view = new App.Views.ThingsShow(model: @model)
      $('#app-container').html(view.render().el)
  </code></pre>
  
  <p>When navigating to <code>http://localhost</code>, I would get the <code>index</code> view rendered, and when clicking on individual elements, I would get the <code>show</code> view rendered. However, if I went to <code>http://localhost/things/1</code> directly (i.e. by typing in the URL), the <code>show</code> view wouldn't be rendered. I realized that this was because the view was being rendered before <code>@collection.fetch</code> was completing. I changed my router to the following:</p>
  
  <pre><code>class App.Routers.ThingsRouter extends Backbone.Router
    routes: '': 'index'
    routes: 'previews/:id': 'show'
  
    initialize: -&gt;
      @collection = new App.Collections.ThingsCollection
  
    index: -&gt;
      @collection.fetch success: =&gt;
        view = new App.Views.ThingsIndex(collection: @collection)
        $('#app-container').html(view.render().el)
  
    show: (id) -&gt;
      @collection.fetch success: =&gt;
        that.model = that.collection.get(id)
        view = new App.Views.ThingsShow(model: @model)
        $('#app-container').html(view.render().el)
  </code></pre>
  
  <p>Which works fine. However, there's obviously a little latency as the collection is re-fetched every time I switch routes. Is this good Backbone practice? Not sure if there's a better way of doing this.</p>