diff options
author | Jozef Selesi <jozefs@users.sourceforge.net> | 2008-11-15 17:39:14 +0000 |
---|---|---|
committer | Jozef Selesi <jozefs@users.sourceforge.net> | 2008-11-15 17:39:14 +0000 |
commit | fbc810098f797d6cacecadb39fab2016ab9a8429 (patch) | |
tree | af688f8ce62b605cfac495f77cc3e8d973a0d263 /modules/comment/views | |
parent | 5e10b44a951a40d9877843b381a5ba6d6c511c48 (diff) |
Do comment add in a single request, some code cleanup.
Diffstat (limited to 'modules/comment/views')
-rw-r--r-- | modules/comment/views/comment_form.html.php | 20 |
1 files changed, 8 insertions, 12 deletions
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("<?= url::site("photo/{$item_id}/comments") ?>", function(data) { - $("#gCommentThread").html(data); - }); -} // ]]> </script> <span id="gCommentAddLink"> @@ -35,5 +31,5 @@ function reload_comments() { <?= _("Add Comment") ?> </a> </span> -<div id="gAddCommentFormContainer"></div> +<div id="gCommentAddFormContainer"></div> |