Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

BMM #3, “Show x more comments” deletes text in comment box when clicked #3313

Merged
merged 1 commit into from

3 participants

Dan Hansen Don't Add Me To Your Organization a.k.a The Travis Bot Maxwell Salzberg
Dan Hansen
Collaborator

persist unsaved comment value after expanding comments

Dan Hansen bugmash #3
persist unsaved comment value after expanding comments
d334097
Don't Add Me To Your Organization a.k.a The Travis Bot

This pull request passes (merged d334097 into f19f611).

Maxwell Salzberg
Owner

I think comments.fetch would be async, since the success callback. wouldn't this still get blown away when the collection finishes?

Dan Hansen
Collaborator

No, we render the view after the model has been populated with comments. After the view is re-rendered we set the textbox's value to what the comment used to be.

Maxwell Salzberg
Owner

cool. done

Maxwell Salzberg maxwell merged commit fb1fd66 into from
Hans Fase hfase01 referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
Hans Fase hfase01 referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
Alexander Wenzowski wenzowski referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 25, 2012
  1. bugmash #3

    Dan Hansen authored
    persist unsaved comment value after expanding comments
This page is out of date. Refresh to see the latest.
8 app/assets/javascripts/app/views/comment_stream_view.js
View
@@ -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()
}
});
}
-
});
16 spec/javascripts/app/views/comment_stream_view_spec.js
View
@@ -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!");
+ })
+ })
})
Something went wrong with that request. Please try again.