[jQuery] Re: [validate] invalidHandler is called before the errors are shown, maybe better vice versa?
The suggestion makes sense, though there are probably also cases where the current order makes more sense, and changing it will cause other issues. Take a look at this tabs demo for an alternative implementation: http://jquery.bassistance.de/validate/demo/tabs/ Jörn On Fri, Apr 17, 2009 at 12:26 PM, snobo g...@riga.ahlers.com wrote: Hi Jörn, incredibly awesome plugin you've made, thanks a million! Started to explore and using it, and stumbled onto situation. In my invalidHandler, I'm trying to access the first input which is marked as invalid (in order to ensure that it is visible - my form is split on tabs, and I need to select a proper tab if the currently selected one has no invalid fields). I'm doing this via $ ('#myform :input.error:first') query, but there is a problem: in your code, you mark fields as invalid AFTER the invalidHandler call (line 302): if (!this.valid()) $(this.currentForm).triggerHandler(invalid-form, [this]); this.showErrors(); So, as a workaround at the moment I simply call showErrors(); in my invalidHandler, but maybe - unless you have a special reason for this - it's better to swap these lines in the jquery.validate.js? That's actually my $0.02 suggestion. cheers
[jQuery] Re: [validate] invalidHandler is called before the errors are shown, maybe better vice versa?
Hmm, interesting alternative solution! Thanx, I will consider this. Well, if you are sure there WILL be issues, let it be, although purely theoretically for me it seems more logical to have invalidHandler being run at the moment where errors are shown. cheers On Apr 17, 1:55 pm, Jörn Zaefferer joern.zaeffe...@googlemail.com wrote: The suggestion makes sense, though there are probably also cases where the current order makes more sense, and changing it will cause other issues. Take a look at this tabs demo for an alternative implementation:http://jquery.bassistance.de/validate/demo/tabs/ Jörn On Fri, Apr 17, 2009 at 12:26 PM, snobo g...@riga.ahlers.com wrote: Hi Jörn, incredibly awesome plugin you've made, thanks a million! Started to explore and using it, and stumbled onto situation. In my invalidHandler, I'm trying to access the first input which is marked as invalid (in order to ensure that it is visible - my form is split on tabs, and I need to select a proper tab if the currently selected one has no invalid fields). I'm doing this via $ ('#myform :input.error:first') query, but there is a problem: in your code, you mark fields as invalid AFTER the invalidHandler call (line 302): if (!this.valid()) $(this.currentForm).triggerHandler(invalid-form, [this]); this.showErrors(); So, as a workaround at the moment I simply call showErrors(); in my invalidHandler, but maybe - unless you have a special reason for this - it's better to swap these lines in the jquery.validate.js? That's actually my $0.02 suggestion. cheers
[jQuery] Re: [validate] invalidHandler is called before the errors are shown, maybe better vice versa?
Sure, it makes sense. Its just not that easy a descision to change something in a stable API. Jörn On Fri, Apr 17, 2009 at 2:55 PM, snobo g...@riga.ahlers.com wrote: Hmm, interesting alternative solution! Thanx, I will consider this. Well, if you are sure there WILL be issues, let it be, although purely theoretically for me it seems more logical to have invalidHandler being run at the moment where errors are shown. cheers On Apr 17, 1:55 pm, Jörn Zaefferer joern.zaeffe...@googlemail.com wrote: The suggestion makes sense, though there are probably also cases where the current order makes more sense, and changing it will cause other issues. Take a look at this tabs demo for an alternative implementation:http://jquery.bassistance.de/validate/demo/tabs/ Jörn On Fri, Apr 17, 2009 at 12:26 PM, snobo g...@riga.ahlers.com wrote: Hi Jörn, incredibly awesome plugin you've made, thanks a million! Started to explore and using it, and stumbled onto situation. In my invalidHandler, I'm trying to access the first input which is marked as invalid (in order to ensure that it is visible - my form is split on tabs, and I need to select a proper tab if the currently selected one has no invalid fields). I'm doing this via $ ('#myform :input.error:first') query, but there is a problem: in your code, you mark fields as invalid AFTER the invalidHandler call (line 302): if (!this.valid()) $(this.currentForm).triggerHandler(invalid-form, [this]); this.showErrors(); So, as a workaround at the moment I simply call showErrors(); in my invalidHandler, but maybe - unless you have a special reason for this - it's better to swap these lines in the jquery.validate.js? That's actually my $0.02 suggestion. cheers