Do comment add in a single request, some code cleanup.

This commit is contained in:
Jozef Selesi
2008-11-15 17:39:14 +00:00
parent 5e10b44a95
commit fbc810098f
2 changed files with 18 additions and 15 deletions

View File

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