Skip to content

Commit

Permalink
Fix issue where submit button would remain disabled after errors on f…
Browse files Browse the repository at this point in the history
…rontend
  • Loading branch information
Dave Earley committed Aug 14, 2016
1 parent 83d9cba commit b78aa6f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
12 changes: 8 additions & 4 deletions public/assets/javascript/app-public.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ $(function() {
Please try again, or contact the webmaster if the problem persists.');
},
success: function(data, statusText, xhr, $form) {
var $submitButton = $form.find('input[type=submit]');

if (data.message) {
showMessage(data.message);
Expand All @@ -46,9 +47,6 @@ $(function() {
document.location.href = data.redirectUrl;
}
}

var $submitButton = $form.find('input[type=submit]');
toggleSubmitDisabled($submitButton);
break;

case 'error':
Expand All @@ -60,7 +58,13 @@ $(function() {

default:
break;


}

toggleSubmitDisabled($submitButton);


},
dataType: 'json'
};
Expand Down Expand Up @@ -200,7 +204,7 @@ function processFormErrors($form, errors)
}

/**
* Toggle a submit button disabled/enabled - duh!
* Toggle a submit button disabled/enabled
*
* @param element $submitButton
* @returns void
Expand Down
3 changes: 1 addition & 2 deletions public/assets/javascript/backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -9053,8 +9053,7 @@ $.cf = {
return;
}

showMessage('Whoops!, it looks like something went wrong on our servers.\n\
Please try again, or contact support if the problem persists.');
showMessage('Whoops!, it looks like the server returned an error.');

var $submitButton = $form.find('input[type=submit]');
toggleSubmitDisabled($submitButton);
Expand Down
16 changes: 10 additions & 6 deletions public/assets/javascript/frontend.js
Original file line number Diff line number Diff line change
Expand Up @@ -4596,11 +4596,12 @@ function log() {
}

toggleSubmitDisabled($submitButton);
showMessage('Whoops!, it looks like something went wrong on our servers.\n\
Please try again, or contact support if the problem persists.');
showMessage('Whoops!, it looks like the server returned an error.\n\
Please try again, or contact the webmaster if the problem persists.');
},
success: function(data, statusText, xhr, $form) {

var $submitButton = $form.find('input[type=submit]');

if (data.message) {
showMessage(data.message);
}
Expand All @@ -4614,9 +4615,6 @@ function log() {
document.location.href = data.redirectUrl;
}
}

var $submitButton = $form.find('input[type=submit]');
toggleSubmitDisabled($submitButton);
break;

case 'error':
Expand All @@ -4628,7 +4626,13 @@ function log() {

default:
break;


}

toggleSubmitDisabled($submitButton);


},
dataType: 'json'
};
Expand Down

0 comments on commit b78aa6f

Please sign in to comment.