Created
July 15, 2014 12:54
-
-
Save dkavanagh/32874d28420cabc90816 to your computer and use it in GitHub Desktop.
foundation abide patch to allow skipping validation for a form cancel button
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
index 9898eac..44eab0e 100644 | |
--- a/eucaconsole/static/js/thirdparty/foundation/foundation.abide.js | |
+++ b/eucaconsole/static/js/thirdparty/foundation/foundation.abide.js | |
@@ -53,7 +53,8 @@ | |
events : function (scope) { | |
var self = this, | |
form = $(scope).attr('novalidate', 'novalidate'), | |
- settings = form.data('abide-init'); | |
+ settings = form.data('abide-init'), | |
+ cancel_target = form.attr('cancel-target'); | |
form | |
.off('.abide') | |
@@ -63,9 +64,17 @@ | |
}) | |
.find('input, textarea, select') | |
.off('.abide') | |
- .on('blur.fndtn.abide change.fndtn.abide', function (e) { | |
+ .on('change.fndtn.abide', function (e) { | |
self.validate([this], e); | |
}) | |
+ .on('blur.fndtn.abide', function (e) { | |
+ if (cancel_target !== undefined) { | |
+ self.blur_target = this; | |
+ } | |
+ else { | |
+ self.validate([this], e); | |
+ } | |
+ }) | |
.on('keydown.fndtn.abide', function (e) { | |
var settings = $(this).closest('form').data('abide-init'); | |
clearTimeout(self.timer); | |
@@ -73,6 +82,11 @@ | |
self.validate([this], e); | |
}.bind(this), settings.timeout); | |
}); | |
+ if (cancel_target) { | |
+ form.find(':not('+cancel_target+')').on('focus.fndtn.abide', function (e) { | |
+ self.validate([self.blur_target], e); | |
+ }) | |
+ } | |
}, | |
validate : function (els, e, is_ajax) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment