Commit 894b62ba by Greg Price

Merge pull request #406 from edx/gprice/register-button-enabling-tweak

Tweak behavior of submit buttons on register and login pages
parents 978d33ba 7c5943a8
...@@ -38,13 +38,12 @@ ...@@ -38,13 +38,12 @@
toggleSubmitButton(false); toggleSubmitButton(false);
}); });
$('#login-form').on('ajax:complete', function() { $('#login-form').on('ajax:error', function() {
toggleSubmitButton(true); toggleSubmitButton(true);
}); });
$('#login-form').on('ajax:success', function(event, json, xhr) { $('#login-form').on('ajax:success', function(event, json, xhr) {
if(json.success) { if(json.success) {
$('.message.submission-error').removeClass('is-shown');
var u=decodeURI(window.location.search); var u=decodeURI(window.location.search);
next=u.split("next=")[1]; next=u.split("next=")[1];
if (next) { if (next) {
...@@ -53,6 +52,7 @@ ...@@ -53,6 +52,7 @@
location.href="${reverse('dashboard')}"; location.href="${reverse('dashboard')}";
} }
} else { } else {
toggleSubmitButton(true);
$('.message.submission-error').addClass('is-shown').focus(); $('.message.submission-error').addClass('is-shown').focus();
$('.message.submission-error .message-copy').html(json.value); $('.message.submission-error .message-copy').html(json.value);
} }
......
...@@ -45,15 +45,15 @@ ...@@ -45,15 +45,15 @@
toggleSubmitButton(false); toggleSubmitButton(false);
}); });
$('#register-form').on('ajax:complete', function() { $('#register-form').on('ajax:error', function() {
toggleSubmitButton(true); toggleSubmitButton(true);
}); });
$('#register-form').on('ajax:success', function(event, json, xhr) { $('#register-form').on('ajax:success', function(event, json, xhr) {
if(json.success) { if(json.success) {
$('.message.submission-error').removeClass('is-shown');
location.href="${reverse('dashboard')}"; location.href="${reverse('dashboard')}";
} else { } else {
toggleSubmitButton(true);
$('.status.message.submission-error').addClass('is-shown').focus(); $('.status.message.submission-error').addClass('is-shown').focus();
$('.status.message.submission-error .message-copy').html(json.value).stop().css("display", "block"); $('.status.message.submission-error .message-copy').html(json.value).stop().css("display", "block");
$(".field-error").removeClass('field-error'); $(".field-error").removeClass('field-error');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment