Always append new posts to the “posts” div.
[Sone.git] / src / main / resources / static / javascript / sone.js
index 02a02a8..1944efe 100644 (file)
@@ -256,7 +256,7 @@ function getFormPassword() {
 }
 
 function getSoneElement(element) {
-       return $(element).parents(".sone");
+       return $(element).closest(".sone");
 }
 
 /**
@@ -694,7 +694,7 @@ function loadNewPost(postId) {
                        if (firstOlderPost != null) {
                                newPost.insertBefore(firstOlderPost);
                        } else {
-                               $("#sone .post:last").append(newPost);
+                               $("#sone #posts").append(newPost);
                        }
                        ajaxifyPost(newPost);
                        newPost.slideDown();
@@ -830,7 +830,7 @@ $(document).ready(function() {
                registerInputTextareaSwap("#sone #post-message input[name=text]", defaultText, "text", false, false);
                $("#sone #post-message").submit(function() {
                        text = $(this).find(":input:enabled").val();
-                       $.getJSON("ajax/createPost.ajax", { "formPassword": getFormPassword(), "recipient": $("#sone #sone-id").text(), "text": text }, function(data, textStatus) {
+                       $.getJSON("createPost.ajax", { "formPassword": getFormPassword(), "recipient": getShownSoneId(), "text": text }, function(data, textStatus) {
                                if ((data != null) && data.success) {
                                        loadNewPost(data.postId);
                                }