summaryrefslogtreecommitdiff
path: root/modules/comment/js/comment.js
blob: 259b48264514888972fc5a37fb3f61db6e631594 (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() {
  $("#gComments form").ajaxForm({
    complete: function(xhr, statusText) {
      $("#gComments form").replaceWith(xhr.responseText);
      if (xhr.status == 201) {
        $.get(xhr.getResponseHeader("Location"), function(data, textStatus) {
          $("#gComments .gBlockContent ul:first").append("<li>"+data+"</li>");
          $("#gComments .gBlockContent ul:first li:last").hide().slideDown();
        });
        $("#gComments form").clearForm();
      }
      ajaxify_comment_form();
    }
  });
}