DC fix back button to profile with this.deferred reference

This commit is contained in:
danielgrippi 2012-05-17 11:47:17 -07:00
parent ed6785d7cb
commit e5206f3429
2 changed files with 20 additions and 15 deletions

View file

@ -59,11 +59,14 @@ app.models.Stream = Backbone.Collection.extend({
}, },
preloadOrFetch : function(){ //hai, plz test me THNX preloadOrFetch : function(){ //hai, plz test me THNX
return $.when(app.hasPreload("stream") ? this.preload() : this.fetch()) app.hasPreload("stream") ? this.preload() : this.fetch()
return this.deferred
}, },
preload : function(){ preload : function(){
this.items.reset(app.parsePreload("stream")) this.items.reset(app.parsePreload("stream"))
this.trigger("fetched") this.trigger("fetched")
this.deferred = $.when(true)
} }
}); });

View file

@ -9,23 +9,25 @@ app.views.Canvas = app.views.Base.extend(_.extend({}, app.views.infiniteScrollMi
}, },
renderTemplate : function() { renderTemplate : function() {
if(this.stream.items.isEmpty()){ this.stream.deferred.done(_.bind(function(){
var message if(this.stream.items.isEmpty()){
, person = app.page.model var message
if(person.get("is_own_profile")){ , person = app.page.model
message = "Make something to start the magic." if(person.get("is_own_profile")){
message = "Make something to start the magic."
} else {
var name = person.get("name") || ""
message = name + " hasn't posted anything yet."
}
this.$el.html("<p class='no-post-message'>" + message + "</p>")
} else { } else {
var name = person.get("name") || "" this.renderInitialPosts()
message = name + " hasn't posted anything yet."
} }
this.$el.html("<p class='no-post-message'>" + message + "</p>") //needs to be deferred so it happens after html rendering finishes
} else { _.defer(_.bind(this.mason, this))
this.renderInitialPosts() }, this))
}
//needs to be deferred so it happens after html rendering finishes
_.defer(_.bind(this.mason, this))
}, },
addPostView : function(post) { addPostView : function(post) {