Prevent spinner from spinning on required form entry

This commit is contained in:
kapito 2016-04-28 17:08:33 +01:00 committed by Matt Westcott
parent 9bf921f611
commit 7a0d37f6e9
3 changed files with 9 additions and 0 deletions

View file

@ -11,6 +11,7 @@ Changelog
* Fix: Redirects no longer fail when both a site-specific and generic redirect exist for the same URL path (Nick Smith, João Luiz Lorencetti)
* Fix: Wagtail now checks that Group is registered with the Django admin before unregistering it (Jason Morrison)
* Fix: Previewing inaccessible pages no longer fails with `ALLOWED_HOSTS = ['*']` (Robert Rollins)
* Fix: The submit button 'spinner' no longer activates if the form has client-side validation errors (Jack Paine, Matt Westcott)
1.4.3 (04.04.2016)

View file

@ -20,3 +20,4 @@ Bug fixes
* Redirects no longer fail when both a site-specific and generic redirect exist for the same URL path (Nick Smith, João Luiz Lorencetti)
* Wagtail now checks that Group is registered with the Django admin before unregistering it (Jason Morrison)
* Previewing inaccessible pages no longer fails with ``ALLOWED_HOSTS = ['*']`` (Robert Rollins)
* The submit button 'spinner' no longer activates if the form has client-side validation errors (Jack Paine, Matt Westcott)

View file

@ -223,6 +223,13 @@ $(function() {
var reEnableAfter = 30;
var dataName = 'disabledtimeout'
// Check the form this submit button belongs to (if any)
var form = $self.closest('form').get(0);
if (form && form.checkValidity && (form.checkValidity() == false)) {
// ^ Check form.checkValidity returns something as it may not be browser compatible
return;
}
// Disabling a button prevents it submitting the form, so disabling
// must occur on a brief timeout only after this function returns.