diff options
author | Bharat Mediratta <bharat@menalto.com> | 2009-09-13 14:19:04 -0700 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2009-09-13 14:19:04 -0700 |
commit | 21d6e17efafbbb249f13c0344abf2dad9a812103 (patch) | |
tree | f76e369963721f904299ac62ff7c00798ebe7e98 | |
parent | 827c845abbfe0767cb5063fea372477c24713b1e (diff) |
Don't add another comment form every time you click the [Add a
comment] button.
-rw-r--r-- | modules/comment/js/comment.js | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/modules/comment/js/comment.js b/modules/comment/js/comment.js index 9fd63c1a..bff83770 100644 --- a/modules/comment/js/comment.js +++ b/modules/comment/js/comment.js @@ -1,13 +1,15 @@ $("document").ready(function() { $("#gAddCommentButton").click(function(event) { event.preventDefault(); - $.get($(this).attr("href"), - {}, - function(data) { - $("#gCommentDetail").append(data); - ajaxify_comment_form(); - }); - }); + if (!$("#gAddCommentForm").length) { + $.get($(this).attr("href"), + {}, + function(data) { + $("#gCommentDetail").append(data); + ajaxify_comment_form(); + }); + } + }); }); function ajaxify_comment_form() { @@ -22,7 +24,7 @@ function ajaxify_comment_form() { $.get(data.resource, function(data, textStatus) { $("#gComments .gBlockContent ul:first").append("<li>"+data+"</li>"); $("#gComments .gBlockContent ul:first li:last").effect("highlight", {color: "#cfc"}, 8000); - $("#gAddCommentForm").hide(2000); + $("#gAddCommentForm").hide(2000).remove(); $("#gNoCommentsYet").hide(2000); }); } |