Skip to content
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

Don't revalidate if already validated and field value hasn't changed. #2

Open
garygreen opened this issue Jul 1, 2015 · 2 comments

Comments

@garygreen
Copy link
Owner

Especially useful for remoteRule so it won't fire new requests if value was already validated and hasn't changed.

@RichAyotte
Copy link

Here's a workaround. Let me know what you think about the strategy and I might be able to send you a PR, without the dependence on jquery-aop of course.

Oct 23: Updated workaround

$('form').bind('dominar.init-field', function(event) {
    event.dominarField.$field.on('keyup paste', function() {
        event.dominarField.$container.removeClass('has-success');
    });
});


$.aop.around({
    target: validator.DominarField
    , method: 'validate'
}, function(invocation) {
    if (this.$container.hasClass('has-success')) {
        if (typeof invocation.arguments[0] === 'function') {  // passes
            return invocation.arguments[0]()
        };
    }
    return invocation.proceed();
});

@vlascik
Copy link

vlascik commented Nov 25, 2015

This would be most helpful, remote requests are firing several times needlessly, but maybe just store the last validated value and validation result for each field, and compare them before validating again, instead of removing classes?

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

No branches or pull requests

3 participants