Last active
December 23, 2015 17:19
-
-
Save tommyp/6668117 to your computer and use it in GitHub Desktop.
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 Shsh.Views.AssetsIndex extends Backbone.View | |
template: JST['assets/index'] | |
initalize: -> | |
@collection.on('reset', @render, this) | |
render: -> | |
$(@el).html(@template(assets: @collection)) | |
console.log('rendered') | |
this |
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 Shsh.Routers.Assets extends Backbone.Router | |
routes: | |
'': 'index' | |
initialize: -> | |
@collection = new Shsh.Collections.Assets() | |
@collection.fetch({reset: true}) | |
index: -> | |
view = new Shsh.Views.AssetsIndex(collection: @collection) | |
$('#container').html(view.render().el) |
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
h1 Hiya!! | |
p = @assets.length |
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
[{"created_at":"2013-09-19T14:28:37Z","id":1,"title":"Asset 0","updated_at":"2013-09-19T14:28:37Z"},{"created_at":"2013-09-19T14:28:37Z","id":2,"title":"Asset 1","updated_at":"2013-09-19T14:28:37Z"},{"created_at":"2013-09-19T14:28:37Z","id":3,"title":"Asset 2","updated_at":"2013-09-19T14:28:37Z"},{"created_at":"2013-09-19T14:28:37Z","id":4,"title":"Asset 3","updated_at":"2013-09-19T14:28:37Z"},{"created_at":"2013-09-19T14:28:37Z","id":5,"title":"Asset 4","updated_at":"2013-09-19T14:28:37Z"},{"created_at":"2013-09-19T14:28:37Z","id":6,"title":"Asset 5","updated_at":"2013-09-19T14:28:37Z"},{"created_at":"2013-09-19T14:28:37Z","id":7,"title":"Asset 6","updated_at":"2013-09-19T14:28:37Z"},{"created_at":"2013-09-19T14:28:37Z","id":8,"title":"Asset 7","updated_at":"2013-09-19T14:28:37Z"},{"created_at":"2013-09-19T14:28:37Z","id":9,"title":"Asset 8","updated_at":"2013-09-19T14:28:37Z"},{"created_at":"2013-09-19T14:28:37Z","id":10,"title":"Asset 9","updated_at":"2013-09-19T14:28:37Z"}] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So the view gets rendered, @assets.length comes back as zero, but there's 10 in the DB. Maybe I'm wrong, but wouldn't the console.log('rendered') come back twice?
If I trigger all the steps manually in the console, it gets updated with 10.