summaryrefslogtreecommitdiff
path: root/app/assets/javascripts
diff options
context:
space:
mode:
authorAzul <azul@riseup.net>2017-03-23 10:43:11 +0100
committerAzul <azul@riseup.net>2017-03-23 11:04:21 +0100
commitc828d0164a43c169775ae107be3fd4409d6c3ecb (patch)
tree0611aeffde20fab088eacb2cac0736258bf789f3 /app/assets/javascripts
parent3efe125d6e3bd5f4eecd18952376ffc37e09b9c5 (diff)
fix: keep ticket submit button clickable
It was marked as submitted even when client side validations interfered. fixes github issue #227
Diffstat (limited to 'app/assets/javascripts')
-rw-r--r--app/assets/javascripts/buttons.js17
1 files changed, 11 insertions, 6 deletions
diff --git a/app/assets/javascripts/buttons.js b/app/assets/javascripts/buttons.js
index 7142957..aaa9911 100644
--- a/app/assets/javascripts/buttons.js
+++ b/app/assets/javascripts/buttons.js
@@ -5,12 +5,12 @@
*
* Some form inputs are validaded before the submission
* so triggering loading state on click events is not a
- * good idea. If the validation fails the errors will
+ * good idea. If the validation fails the errors will
* be displayed but the button would be in loading state.
*
* We used to trigger it based on form submission but
* we have a few forms that contain multiple buttons.
- * So now we mark the buttons as clicked on click and
+ * So now we mark the buttons as clicked on click and
* put the clicked button into loading state on submit.
*
*/
@@ -26,14 +26,19 @@
markAsLoading = function(submitEvent) {
var form = submitEvent.target;
- $(form).addClass('submitted')
- // bootstrap loading state:
- $(form).find('.btn.clicked[type="submit"]').button('loading');
+ var validations = form.ClientSideValidations
+
+ if ( ( typeof validations === 'undefined' ) ||
+ $(form).isValid(validations.settings.validators) ) {
+ $(form).addClass('submitted')
+ // bootstrap loading state:
+ $(form).find('.btn.clicked[type="submit"]').button('loading');
+ }
};
$(document).ready(function() {
$('form').submit(markAsLoading);
$('.btn[type="submit"]').click(markAsClicked);
});
-
+
}).call(this);