Create new scopes to not lose the element we’re unmarking.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 25 Nov 2010 14:50:26 +0000 (15:50 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 25 Nov 2010 14:50:26 +0000 (15:50 +0100)
src/main/resources/static/javascript/sone.js

index 32ad683..e7d19e6 100644 (file)
@@ -659,9 +659,11 @@ function markPostAsKnown(postElements) {
        $(postElements).each(function() {
                postElement = this;
                if ($(postElement).hasClass("new")) {
-                       $.getJSON("ajax/markPostAsKnown.ajax", {"formPassword": getFormPassword(), "post": getPostId(postElement)}, function(data, textStatus) {
-                               $(postElement).removeClass("new");
-                       });
+                       (function(postElement) {
+                               $.getJSON("ajax/markPostAsKnown.ajax", {"formPassword": getFormPassword(), "post": getPostId(postElement)}, function(data, textStatus) {
+                                       $(postElement).removeClass("new");
+                               });
+                       })(postElement);
                }
        });
        markReplyAsKnown($(postElements).find(".reply"));
@@ -671,9 +673,11 @@ function markReplyAsKnown(replyElements) {
        $(replyElements).each(function() {
                replyElement = this;
                if ($(replyElement).hasClass("new")) {
-                       $.getJSON("ajax/markReplyAsKnown.ajax", {"formPassword": getFormPassword(), "reply": getReplyId(replyElement)}, function(data, textStatus) {
-                               $(replyElement).removeClass("new");
-                       });
+                       (function(replyElement) {
+                               $.getJSON("ajax/markReplyAsKnown.ajax", {"formPassword": getFormPassword(), "reply": getReplyId(replyElement)}, function(data, textStatus) {
+                                       $(replyElement).removeClass("new");
+                               });
+                       })(replyElement);
                }
        });
 }