client_side_validations icon indicating copy to clipboard operation
client_side_validations copied to clipboard

redundant calling of form callbacks

Open kellerapps opened this issue 14 years ago • 6 comments

Shouldn't the form callbacks be called once per validation? The each loop below seems to validate the form once per field instead of once per form.

  validateForm = function(form, validators) {
    var valid;
    valid = true;
    form.trigger('form:validate:before').find('[data-validate="true"]:input:enabled').each(function() {
      if (!$(this).isValid(validators)) valid = false;
      if (valid) {
        form.trigger('form:validate:pass');
      } else {
        form.trigger('form:validate:fail');
      }
      return form.trigger('form:validate:after');
    });
    return valid;
  };

kellerapps avatar Jan 26 '12 07:01 kellerapps

Yes, this is fixed:

https://github.com/bcardarella/client_side_validations/blob/master/coffeescript/rails.validations.coffee#L68-72

bcardarella avatar Jan 26 '12 08:01 bcardarella

I'm running:

gem 'client_side_validations', '~> 3.2.0.beta.1' gem 'client_side_validations-mongoid', '~> 2.4.0.beta.2'

Also I noticed https://github.com/bcardarella/client_side_validations/wiki/Callbacks asserts one can write:

clientSideValidations.callbacks...

but one must capitalize C as in:

ClientSideValidations.callbacks...

Also, did you ever implement support for :remote=>true?

Thx, Brian. -Ken

On Thu, Jan 26, 2012 at 12:06 AM, Brian Cardarella [email protected] wrote:

Yes, this is fixed:

https://github.com/bcardarella/client_side_validations/blob/master/coffeescript/rails.validations.coffee#L68-72


Reply to this email directly or view it on GitHub: https://github.com/bcardarella/client_side_validations/issues/260#issuecomment-3665626

kellerapps avatar Jan 26 '12 08:01 kellerapps

The changes have not been packaged in a gem yet. I want to close out a few more issues before I package.

No haven't implemented :remote => true yet

bcardarella avatar Jan 26 '12 08:01 bcardarella

Pretty-please implement :remote=>true -- I want to implement modal dialogs/forms. -Ken

On Thu, Jan 26, 2012 at 12:22 AM, Brian Cardarella [email protected] wrote:

The changes have not been packaged in a gem yet. I want to close out a few more issues before I package.

No haven't implemented :remote => true yet


Reply to this email directly or view it on GitHub: https://github.com/bcardarella/client_side_validations/issues/260#issuecomment-3665759

kellerapps avatar Jan 26 '12 08:01 kellerapps

It's under way :)

bcardarella avatar Jan 26 '12 08:01 bcardarella

If the gem can provide a function which injects an errors hash, programmers can call it in an ajax:success handler.

On Thu, Jan 26, 2012 at 12:36 AM, Brian Cardarella [email protected] wrote:

It's under way :)


Reply to this email directly or view it on GitHub: https://github.com/bcardarella/client_side_validations/issues/260#issuecomment-3665872

kellerapps avatar Jan 26 '12 16:01 kellerapps