fix display of comment box after editing and posting

should close #178
This commit is contained in:
joshua stein 2014-11-14 14:02:16 -06:00
parent d6447ac249
commit 4b0caa2752

View file

@ -174,8 +174,12 @@ var _Lobsters = Class.extend({
if ($(form).find('#parent_comment_short_id').length) { if ($(form).find('#parent_comment_short_id').length) {
$(form).closest('.comment').replaceWith($.parseHTML(data)); $(form).closest('.comment').replaceWith($.parseHTML(data));
} else { } else {
$(form).closest('.comment').after($.parseHTML(data)); if ($(form).attr("id").match(/^edit_comment_.+$/)) {
$(form).find('textarea').val(''); $(form).parent(".comment").replaceWith($.parseHTML(data));
} else {
$(form).closest('.comment').after($.parseHTML(data));
$(form).find('textarea').val('');
}
} }
}); });
}, },
@ -313,7 +317,7 @@ $(document).ready(function() {
if (comment.length) { if (comment.length) {
$.get("/comments/" + comment.attr("data-shortid"), $.get("/comments/" + comment.attr("data-shortid"),
function(data) { function(data) {
comment.replaceWith($.parseHTML(data)); comment.html($.parseHTML(data));
}); });
} else { } else {
$(this).closest(".comment").remove(); $(this).closest(".comment").remove();
@ -324,7 +328,7 @@ $(document).ready(function() {
var comment = $(this).closest(".comment"); var comment = $(this).closest(".comment");
$.get("/comments/" + comment.attr("data-shortid") + "/edit", $.get("/comments/" + comment.attr("data-shortid") + "/edit",
function(data) { function(data) {
comment.html($.parseHTML(data)); comment.replaceWith($.parseHTML(data));
}); });
}); });