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

@OhaiBBQ
Collaborator

persist unsaved comment value after expanding comments

Dan Hansen bugmash #3
persist unsaved comment value after expanding comments
d334097
@travisbot

This pull request passes (merged d334097 into f19f611).

@maxwell
Owner

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

@OhaiBBQ
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
Owner

cool. done

@maxwell maxwell merged commit fb1fd66 into from
@hfase01 hfase01 referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@hfase01 hfase01 referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@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.
View
8 app/assets/javascripts/app/views/comment_stream_view.js
@@ -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()
}
});
}
-
});
View
16 spec/javascripts/app/views/comment_stream_view_spec.js
@@ -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.