From 7c5943a87c0a28aced02e3210b0078e5958c79c4 Mon Sep 17 00:00:00 2001 From: Greg Price Date: Fri, 21 Jun 2013 13:05:48 -0400 Subject: [PATCH] Tweak behavior of submit buttons on register and login pages The buttons are not re-enabled if the registration/login submission succeeds (and, therefore, the user is about to be directed to another page). Also, any error message that is present does not disappear immediately before the page redirects. --- lms/templates/login.html | 4 ++-- lms/templates/register.html | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lms/templates/login.html b/lms/templates/login.html index 671ce5a3e7..5ab63a86c2 100644 --- a/lms/templates/login.html +++ b/lms/templates/login.html @@ -38,13 +38,12 @@ toggleSubmitButton(false); }); - $('#login-form').on('ajax:complete', function() { + $('#login-form').on('ajax:error', function() { toggleSubmitButton(true); }); $('#login-form').on('ajax:success', function(event, json, xhr) { if(json.success) { - $('.message.submission-error').removeClass('is-shown'); var u=decodeURI(window.location.search); next=u.split("next=")[1]; if (next) { @@ -53,6 +52,7 @@ location.href="${reverse('dashboard')}"; } } else { + toggleSubmitButton(true); $('.message.submission-error').addClass('is-shown').focus(); $('.message.submission-error .message-copy').html(json.value); } diff --git a/lms/templates/register.html b/lms/templates/register.html index 1c2490c0a0..57a9ffa843 100644 --- a/lms/templates/register.html +++ b/lms/templates/register.html @@ -45,15 +45,15 @@ toggleSubmitButton(false); }); - $('#register-form').on('ajax:complete', function() { + $('#register-form').on('ajax:error', function() { toggleSubmitButton(true); }); $('#register-form').on('ajax:success', function(event, json, xhr) { if(json.success) { - $('.message.submission-error').removeClass('is-shown'); location.href="${reverse('dashboard')}"; } else { + toggleSubmitButton(true); $('.status.message.submission-error').addClass('is-shown').focus(); $('.status.message.submission-error .message-copy').html(json.value).stop().css("display", "block"); $(".field-error").removeClass('field-error');