be less agressive when re-rendering on feedback actions
This commit is contained in:
parent
3cab4d348a
commit
3db133a3a7
5 changed files with 27 additions and 2 deletions
|
|
@ -41,6 +41,7 @@ app.models.Post = Backbone.Model.extend({
|
|||
var self = this;
|
||||
this.participations.create({}, {success : function(resp){
|
||||
self.set(resp.attributes.post)
|
||||
self.trigger('feedback', self)
|
||||
}});
|
||||
},
|
||||
|
||||
|
|
@ -50,6 +51,8 @@ app.models.Post = Backbone.Model.extend({
|
|||
|
||||
participationModel.destroy();
|
||||
this.set({ user_participation : null });
|
||||
|
||||
this.trigger('feedback', this)
|
||||
},
|
||||
|
||||
toggleLike : function() {
|
||||
|
|
@ -65,6 +68,7 @@ app.models.Post = Backbone.Model.extend({
|
|||
var self = this;
|
||||
this.likes.create({}, {success : function(resp){
|
||||
self.set(resp.attributes.post)
|
||||
self.trigger('feedback', self)
|
||||
}});
|
||||
},
|
||||
|
||||
|
|
@ -74,5 +78,6 @@ app.models.Post = Backbone.Model.extend({
|
|||
|
||||
likeModel.destroy();
|
||||
this.set({ user_like : null });
|
||||
this.trigger('feedback', this)
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ app.pages.PostViewer = app.views.Base.extend({
|
|||
postView : function(){
|
||||
return new app.views.Post({
|
||||
model : this.model,
|
||||
className : "dd",
|
||||
className : "loaded",
|
||||
templateName : "post-viewer/content/" + this.options.postTemplateName
|
||||
})
|
||||
},
|
||||
|
|
|
|||
|
|
@ -10,7 +10,11 @@ app.views.Base = Backbone.View.extend({
|
|||
|
||||
setupRenderEvents : function(){
|
||||
this.model.bind('remove', this.remove, this);
|
||||
this.model.bind('change', this.render, this);
|
||||
|
||||
// this line is too generic. we usually only want to re-render on
|
||||
// feedback changes as the post content, author, and time do not change.
|
||||
//
|
||||
// this.model.bind('change', this.render, this);
|
||||
},
|
||||
|
||||
defaultPresenter : function(){
|
||||
|
|
|
|||
|
|
@ -10,6 +10,14 @@ app.views.Feedback = app.views.Base.extend({
|
|||
"click .reshare_action": "resharePost"
|
||||
},
|
||||
|
||||
initialize : function() {
|
||||
this.model.bind('feedback', this.render, this);
|
||||
},
|
||||
|
||||
postRenderTemplate : function(){
|
||||
console.log('fuck')
|
||||
},
|
||||
|
||||
presenter : function() {
|
||||
return _.extend(this.defaultPresenter(), {
|
||||
userCanReshare : this.userCanReshare()
|
||||
|
|
|
|||
|
|
@ -16,6 +16,14 @@ describe("app.views.Feedback", function(){
|
|||
});
|
||||
|
||||
|
||||
describe("triggers", function() {
|
||||
it('re-renders when the model triggers feedback', function(){
|
||||
spyOn(this.view, "postRenderTemplate")
|
||||
this.view.model.trigger("feedback")
|
||||
expect(this.view.postRenderTemplate).toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
|
||||
describe(".render", function(){
|
||||
beforeEach(function(){
|
||||
this.link = function(){ return this.view.$(".like_action"); }
|
||||
|
|
|
|||
Loading…
Reference in a new issue