From 0bb82b76216d033742afab91ce9e9a20dd607ad8 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 25 Dec 2008 00:47:40 +0000 Subject: Gut the comment module and simplify it. Stop trying to support Atom and XML for now, we have no driver for those technologies so anything we implement is not going to be sufficiently tested and therefore it'll be broken. Change all comment functions to return JSON and update the JS to deal purely with JSON. This is our new protocol for talking to the browser and it should be flexible and portable. Create comments.html.php. This duplicates comment.html.php, but will be more efficient for rendering comments since we won't be creating a new View for every comment we render. --- modules/comment/js/comment.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'modules/comment/js/comment.js') diff --git a/modules/comment/js/comment.js b/modules/comment/js/comment.js index 259b4826..d251ac96 100644 --- a/modules/comment/js/comment.js +++ b/modules/comment/js/comment.js @@ -4,16 +4,17 @@ $("document").ready(function() { 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) { + dataType: 'json', + success: function(data) { + if (data.result == "success") { + $.get(data.resource, function(data, textStatus) { $("#gComments .gBlockContent ul:first").append("
  • "+data+"
  • "); $("#gComments .gBlockContent ul:first li:last").hide().slideDown(); }); $("#gComments form").clearForm(); } + $("#gComments form").replaceWith(data.form); ajaxify_comment_form(); } }); -} +}; -- cgit v1.2.3