cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Larson <...@keow.org>
Subject Re: v2 Form.js how does onValidate work?
Date Thu, 18 Mar 2004 14:33:51 GMT
On Wed, Mar 17, 2004 at 02:31:53PM -0800, Christopher Oliver wrote:
> Tim Larson wrote:
> >On Wed, Mar 17, 2004 at 11:18:35AM -0800, Christopher Oliver wrote:
> >>Tim Larson wrote:
> >>>On Tue, Mar 16, 2004 at 09:16:38PM +0000, Tim Larson wrote:
> >>> var userErrors = 0;
> >>> this.formWidget_.validationErrorListener = function(widget, error) {
> >>>     if (error != null) {
> >>>         userErrors++;
> >>>     }
> >>> }
>
> Perhaps what seems strange to you is that the "userErrors" variable is 
> part of the closure of the function that is set as the 
> validationErrorListener property on the form widget. Thus calls to that 
> function modify its value in the call frame of showForm().

That is what I missed, that we were setting a function pointer rather
than calling the function in the snippet above.  Thanks for clearing this
up, Chris.  I am still working on getting comfortable with JavaScript.

My new question is why we set the validationErrorListener function
pointer every time we go through the loop instead of just once.
Is this to protect against the possibility of the user's flowscript
messing with the pointer?

--Tim Larson

Mime
View raw message