diff options
author | Tim Almdal <tnalmdal@shaw.ca> | 2009-11-25 08:05:21 -0800 |
---|---|---|
committer | Tim Almdal <tnalmdal@shaw.ca> | 2009-11-25 08:12:50 -0800 |
commit | 4c3b9e363ab1501bf3169d92f5606abf464c2d5e (patch) | |
tree | 1be0d88b900558895b0e7e1bb5f513fbff6b1348 /modules/comment/js/comment.js | |
parent | 82ee5f9d338017c69331b2907f37a468ced8c66e (diff) |
Refactor the comment module as part of ticket: #917 "Remove Rest Controller"
* Remove the methods create, update, delete, get_edit_form as there are not used
* Change the return when a comment is created to return the html for the new comment.
This saves a second get request to down load the comment.
Diffstat (limited to 'modules/comment/js/comment.js')
-rw-r--r-- | modules/comment/js/comment.js | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/modules/comment/js/comment.js b/modules/comment/js/comment.js index 3f058062..bb204b78 100644 --- a/modules/comment/js/comment.js +++ b/modules/comment/js/comment.js @@ -28,17 +28,16 @@ function ajaxify_comment_form() { $("#g-comments form").ajaxForm({ dataType: "json", success: function(data) { - if (data.form) { - $("#g-comments form").replaceWith(data.form); - ajaxify_comment_form(); - } - if (data.result == "success" && data.resource) { - $.get(data.resource, function(data, textStatus) { - $("#g-comments .g-block-content ul:first").append("<li>"+data+"</li>"); - $("#g-comments .g-block-content ul:first li:last").effect("highlight", {color: "#cfc"}, 8000); - $("#g-comment-form").hide(2000).remove(); - $("#g-no-comments-yet").hide(2000); - }); + if (data.result == "success") { + $("#g-comments #g-comment-detail ul").append(data.view); + $("#g-comments #g-comment-detail ul li:last").effect("highlight", {color: "#cfc"}, 8000); + $("#g-comment-form").hide(2000).remove(); + $("#g-no-comments-yet").hide(2000); + } else { + if (data.form) { + $("#g-comments form").replaceWith(data.form); + ajaxify_comment_form(); + } } } }); |