Disable buttons after posting, re-enable after the request finished.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 1 Apr 2011 11:25:26 +0000 (13:25 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 1 Apr 2011 11:25:26 +0000 (13:25 +0200)
src/main/resources/static/javascript/sone.js

index 9ef6812..96c8ad5 100644 (file)
@@ -639,6 +639,8 @@ function ajaxifyPost(postElement) {
                return false;
        });
        $(postElement).find(".create-reply button:submit").click(function() {
+               button = $(this);
+               button.attr("disabled", "disabled");
                sender = $(this.form).find(":input[name=sender]").val();
                inputField = $(this.form).find(":input[name=text]:enabled").get(0);
                postId = getPostId(this);
@@ -655,6 +657,7 @@ function ajaxifyPost(postElement) {
                                } else {
                                        alert(error);
                                }
+                               button.removeAttr("disabled");
                        });
                })(sender, postId, text, inputField);
                return false;
@@ -1298,6 +1301,8 @@ $(document).ready(function() {
                        return false;
                });
                $("#sone #update-status").submit(function() {
+                       button = $("button:submit", this);
+                       button.attr("disabled", "disabled");
                        if ($(this).find(":input.default:enabled").length > 0) {
                                return false;
                        }
@@ -1307,6 +1312,7 @@ $(document).ready(function() {
                                if ((data != null) && data.success) {
                                        loadNewPost(data.postId, data.sone, data.recipient);
                                }
+                               button.removeAttr("disabled");
                        });
                        $(this).find(":input[name=sender]").val(getCurrentSoneId());
                        $(this).find(":input[name=text]:enabled").val("").blur();