Created
September 23, 2013 11:09
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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