summaryrefslogtreecommitdiff
path: root/themes/default/js/comment.js
blob: f88f21e5c99358b22157aac9febe5bce5e957488 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
$("document").ready(function() {
  ajaxify_comment_form();
});

function ajaxify_comment_form() {
  $("#gCommentForm").ajaxForm({
    complete: function(xhr, statusText) {
      $("#gCommentForm").replaceWith(xhr.responseText);
      if (xhr.status == 201) {
        $.get(xhr.getResponseHeader("Location"), function(data, textStatus) {
          $("#gComment div.gBlockContent ul:first").append(data);
          $("#gComment div.gBlockContent ul:first li:last").hide().slideDown();
        });
        $("#gCommentForm").clearForm();
      }
      ajaxify_comment_form();
    }
  });
}