Skip to content

Commit

Permalink
adding cleanup handler for FormValidator behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
anutron committed Nov 1, 2011
1 parent 203a03d commit 622fbb5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 3 additions & 3 deletions Source/Delegators/Delegator.FxReveal.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@ name: Delegator.FxReveal
handler: function(event, link, api){
var targets;
if (api.get('target')){
targets = new Elements(link.getElement(api.get('target')));
targets = new Elements([link.getElement(api.get('target'))]);
if (!targets) api.fail('could not locate target element to ' + action, link);
} else if (api.get('targets')){
targets = link.getElements(api.get('targets'));
if (!targets.length) api.fail('could not locate target elements to ' + action, link);
} else {
targets = new Elements(link);
targets = new Elements([link]);
}

var fxOptions = api.get('fxOptions');
if (fxOptions) targets.set('reveal', fxOptions);
targets.get('reveal');
if (action == 'toggleReveal') targets.get('reveal').invoke('toggle');
else targets[action]();
if (!api.getAsBoolean('allowEvent')) event.preventDefault();
if (!api.getAs(Boolean, 'allowEvent')) event.preventDefault();
}
};

Expand Down
5 changes: 4 additions & 1 deletion Source/Forms/Behavior.FormValidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Behavior.addGlobalFilter('FormValidator', {
//instantiate the form validator
var validator = element.retrieve('validator');
if (!validator) {
validator = new Form.Validator.Inline(element,
validator = new Form.Validator.Inline(element,
Object.cleanValues(
api.getAs({
useTitles: Boolean,
Expand Down Expand Up @@ -56,6 +56,9 @@ Behavior.addGlobalFilter('FormValidator', {
scrollToErrorsOnSubmit: false
});
}
api.onCleanup(function(){
validator.disable();
});
return validator;
}

Expand Down

0 comments on commit 622fbb5

Please sign in to comment.