Fix replies being inserted at the wrong posts if the network is sloooooooow.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 9 Dec 2010 05:13:23 +0000 (06:13 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 9 Dec 2010 05:13:23 +0000 (06:13 +0100)
src/main/resources/static/javascript/sone.js

index b3b8fdc..acb1d46 100644 (file)
@@ -449,16 +449,18 @@ function ajaxifyPost(postElement) {
                inputField = $(this.form).find(":input:enabled").get(0);
                postId = getPostId(this);
                text = $(inputField).val();
-               postReply(postId, text, function(success, error, replyId) {
-                       if (success) {
-                               $(inputField).val("");
-                               loadNewReply(replyId);
-                               markPostAsKnown(getPostElement(inputField));
-                               $("#sone .post#" + postId + " .create-reply").addClass("hidden");
-                       } else {
-                               alert(error);
-                       }
-               });
+               (function(postId, text, inputField) {
+                       postReply(postId, text, function(success, error, replyId) {
+                               if (success) {
+                                       $(inputField).val("");
+                                       loadNewReply(replyId);
+                                       markPostAsKnown(getPostElement(inputField));
+                                       $("#sone .post#" + postId + " .create-reply").addClass("hidden");
+                               } else {
+                                       alert(error);
+                               }
+                       });
+               })(postId, text, inputField);
                return false;
        });