Merge pull request #3313 from OhaiBBQ/master
BMM #3, “Show x more comments” deletes text in comment box when clicked
This commit is contained in:
commit
fb1fd665de
2 changed files with 22 additions and 2 deletions
|
|
@ -61,16 +61,20 @@ app.views.CommentStream = app.views.Base.extend({
|
|||
expandComments: function(evt){
|
||||
if(evt){ evt.preventDefault(); }
|
||||
|
||||
var self = this;
|
||||
var localCommentValue = this.$("textarea").val(),
|
||||
self = this;
|
||||
|
||||
this.model.comments.fetch({
|
||||
success : function(resp){
|
||||
self.model.set({
|
||||
comments : resp.models,
|
||||
all_comments_loaded : true
|
||||
})
|
||||
|
||||
self.model.trigger("commentsExpanded", self)
|
||||
|
||||
self.$("textarea").val(localCommentValue).focus()
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -38,4 +38,20 @@ describe("app.views.CommentStream", function(){
|
|||
expect(comment.set).toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
|
||||
describe("expandComments", function() {
|
||||
it("refills the comment textbox on success", function() {
|
||||
jasmine.Ajax.useMock();
|
||||
|
||||
this.view.render();
|
||||
|
||||
this.view.$("textarea").val("great post!");
|
||||
|
||||
this.view.expandComments();
|
||||
|
||||
mostRecentAjaxRequest().response({ comments : [] });
|
||||
|
||||
expect(this.view.$("textarea").val()).toEqual("great post!");
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in a new issue