From: David ‘Bombe’ Roden Date: Fri, 1 Apr 2011 11:25:26 +0000 (+0200) Subject: Disable buttons after posting, re-enable after the request finished. X-Git-Tag: 0.6^2~26 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=c1bbf1ea049cda1eafec49958dc00c49b4690b33;p=Sone.git Disable buttons after posting, re-enable after the request finished. --- diff --git a/src/main/resources/static/javascript/sone.js b/src/main/resources/static/javascript/sone.js index 9ef6812..96c8ad5 100644 --- a/src/main/resources/static/javascript/sone.js +++ b/src/main/resources/static/javascript/sone.js @@ -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();