Skip to content

Reset callback #172

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 17, 2015
Merged

Reset callback #172

merged 3 commits into from
Dec 17, 2015

Conversation

lucax88x
Copy link

Added a reset callback with documentation with also some gernal documentation on general callbacks which weren't present in the API documentation

@hueitan
Copy link
Owner

hueitan commented Dec 15, 2015

In what case people need resetCallback?

We can do it by ng-click="reset(Form)"

$scope.reset = function (form) {
    $validationProvider.reset(form);
    // callback here
}

@hueitan
Copy link
Owner

hueitan commented Dec 15, 2015

Also this resetCallback will works in every inputs.

@lucax88x
Copy link
Author

it's used to perform graphical variations on html elements when a reset is performed.

Are you sure about your last statement?

@hueitan
Copy link
Owner

hueitan commented Dec 15, 2015

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.

@lucax88x
Copy link
Author

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');
};

@hueitan
Copy link
Owner

hueitan commented Dec 15, 2015

Oh I got your point.

resetCallback has the same purpose as validCallback, invalidCallback

@lucax88x
Copy link
Author

yes, but used when a reset is performed

@hueitan
Copy link
Owner

hueitan commented Dec 16, 2015

Thanks @lucax88x This looks reasonable. 🍻

@Nazanin1369 @lucax88x

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.

@Nazanin1369
Copy link
Collaborator

Agree.
On Dec 15, 2015 7:38 PM, "Huei Tan" [email protected] wrote:

Thanks @lucax88x https://github.com/lucax88x This looks reasonable. [image:
🍻]

@Nazanin1369 https://github.com/Nazanin1369 @lucax88x
https://github.com/lucax88x

We now have a lot of callback within every section.

maybe it's time we need to define the callback SPEC.


Reply to this email directly or view it on GitHub
#172 (comment)
.

@hueitan
Copy link
Owner

hueitan commented Dec 16, 2015

@lucax88x I'm going to merge this feature. Do you want to create a test case for this or I can do it.

@lucax88x
Copy link
Author

@huei90 what if you create a spec for valid callback & invalid callback and I add one for reset?

@hueitan
Copy link
Owner

hueitan commented Dec 17, 2015

Ok thanks @lucax88x I will create another Issue for the spec.

and I merge the reset feature now.

hueitan pushed a commit that referenced this pull request Dec 17, 2015
@hueitan hueitan merged commit bf77647 into hueitan:master Dec 17, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants