Skip to content

Instantly share code, notes, and snippets.

@JonMidhir
Created September 23, 2013 11:09
Show Gist options
  • Save JonMidhir/6669103 to your computer and use it in GitHub Desktop.
Save JonMidhir/6669103 to your computer and use it in GitHub Desktop.
If you're not destroying your collection over the lifetime of the router you can do it this way. Benefit is that the view isn't re-initialized every time you hit a router action, instead you can focus on triggering the right events on it.
class ShiftDock.Routers.Rotas extends Backbone.Router
routes:
'': 'index'
initialize: ->
@collection = new ShiftDock.Collections.Rotas()
@collection.view = new ShiftDock.Views.RotasIndex(collection: @collection, el: '#container')
index: (year, week) ->
@collection.fetch
success: (collection, response) =>
collection.trigger('fetched')
# ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment