Reset callback#172
Conversation
|
In what case people need resetCallback? We can do it by |
|
Also this resetCallback will works in every inputs. |
|
it's used to perform graphical variations on html elements when a reset is performed. Are you sure about your last statement? |
|
https://github.com/lucax88x/angular-validation/blob/blessed/src/validator.directive.js#L229 This works on every on - reset event. <form name="Form1">
<input ... />
<input ... />
<input ... />
<button ng-click="reset(Form1)"></button>
</form>then resetCallback will execute 3 times. |
|
yeah, this is correct, as you can see, the callbacks need a element parameter. for example: this.$validation.validCallback = function(element) {
$(element).removeClass('has-error').addClass('has-success-tick');
};
this.$validation.invalidCallback = function(element) {
$(element).removeClass('has-success-tick').addClass('has-error');
};
this.$validation.resetCallback = function(element) {
$(element).removeClass('has-error').removeClass('has-success-tick');
}; |
|
Oh I got your point. resetCallback has the same purpose as validCallback, invalidCallback |
|
yes, but used when a reset is performed |
|
Thanks @lucax88x This looks reasonable. 🍻 We now have a lot of callback within every section. maybe it's time we need to define the callback SPEC it is easy to confuse which is global callback and each callback. |
|
Agree.
|
|
@lucax88x I'm going to merge this feature. Do you want to create a test case for this or I can do it. |
|
@huei90 what if you create a spec for valid callback & invalid callback and I add one for reset? |
|
Ok thanks @lucax88x I will create another Issue for the spec. and I merge the reset feature now. |
Added a reset callback with documentation with also some gernal documentation on general callbacks which weren't present in the API documentation