From 1133d90dcc05eebde16ee54557d178c5229ff693 Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Thu, 7 Mar 2013 12:38:08 -0500 Subject: [PATCH] Disable submit button on signup form when you've submitted the form --- .../discourse/views/modal/create_account_view.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/views/modal/create_account_view.js b/app/assets/javascripts/discourse/views/modal/create_account_view.js index 748fda88188..bbf1a50fa26 100644 --- a/app/assets/javascripts/discourse/views/modal/create_account_view.js +++ b/app/assets/javascripts/discourse/views/modal/create_account_view.js @@ -14,14 +14,16 @@ Discourse.CreateAccountView = Discourse.ModalBodyView.extend({ complete: false, accountPasswordConfirm: 0, accountChallenge: 0, + formSubmitted: false, submitDisabled: (function() { + if (this.get('formSubmitted')) return true; if (this.get('nameValidation.failed')) return true; if (this.get('emailValidation.failed')) return true; if (this.get('usernameValidation.failed')) return true; if (this.get('passwordValidation.failed')) return true; return false; - }).property('nameValidation.failed', 'emailValidation.failed', 'usernameValidation.failed', 'passwordValidation.failed'), + }).property('nameValidation.failed', 'emailValidation.failed', 'usernameValidation.failed', 'passwordValidation.failed', 'formSubmitted'), passwordRequired: (function() { return this.blank('authOptions.auth_provider'); @@ -252,6 +254,7 @@ Discourse.CreateAccountView = Discourse.ModalBodyView.extend({ createAccount: function() { var challenge, email, name, password, passwordConfirm, username, _this = this; + this.set('formSubmitted', true); name = this.get('accountName'); email = this.get('accountEmail'); password = this.get('accountPassword'); @@ -264,11 +267,13 @@ Discourse.CreateAccountView = Discourse.ModalBodyView.extend({ _this.set('complete', true); } else { _this.flash(result.message, 'error'); + _this.set('formSubmitted', false); } if (result.active) { return window.location.reload(); } }, function() { + _this.set('formSubmitted', false); return _this.flash(Em.String.i18n('create_account.failed'), 'error'); }); }