dominar icon indicating copy to clipboard operation
dominar copied to clipboard

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

Open garygreen opened this issue 9 years ago • 2 comments

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

garygreen avatar Jul 01 '15 08:07 garygreen

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

RichAyotte avatar Aug 18 '15 17:08 RichAyotte

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?

vlascik avatar Nov 25 '15 19:11 vlascik