From fbc810098f797d6cacecadb39fab2016ab9a8429 Mon Sep 17 00:00:00 2001 From: Jozef Selesi Date: Sat, 15 Nov 2008 17:39:14 +0000 Subject: Do comment add in a single request, some code cleanup. --- modules/comment/views/comment_form.html.php | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'modules/comment/views') diff --git a/modules/comment/views/comment_form.html.php b/modules/comment/views/comment_form.html.php index f96023a6..86c76dba 100644 --- a/modules/comment/views/comment_form.html.php +++ b/modules/comment/views/comment_form.html.php @@ -4,30 +4,26 @@ function show_comment_add_form(url) { $("#gCommentAddLink").hide(); $.get(url, function(data) { - $("#gAddCommentFormContainer").html(data); + $("#gCommentAddFormContainer").html(data); ajaxify_comment_add_form(); }); } function ajaxify_comment_add_form() { $("form#gComment").ajaxForm({ - target: "#gAddCommentFormContainer", - success: function(responseText, statusText) { - if (!responseText) { - reload_comments(); + dataType: 'json', + success: function(response_data, status_text) { + if (response_data['valid']) { + $("#gCommentThread").html(response_data["html"]); + $("#gCommentAddFormContainer").html(""); $("#gCommentAddLink").show(); } else { + $("#gCommentAddFormContainer").html(response_data["html"]); ajaxify_comment_add_form(); } }, }); } - -function reload_comments() { - $.get("", function(data) { - $("#gCommentThread").html(data); - }); -} // ]]> @@ -35,5 +31,5 @@ function reload_comments() { -
+
-- cgit v1.2.3