cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Oliver <res1c...@verizon.net>
Subject Re: [Proposal] Implementing XMLForm with Flow
Date Mon, 23 Dec 2002 16:20:20 GMT
Hi Ugo,

Ugo Cei wrote:

>>
>> function checkLogin(funarg)
>> {
>>   if (user == null)
>>     login();
>>   funarg();
>> }
>
>
> This doesn't seem to work. It always generates an error message like 
> "org.mozilla.javascript.EvaluatorException: checkout is not a function."
>
> But if I invoke the same function directly from the sitemap, without 
> passing its name as an argument, it works.
>
> What's happening here?
>
>     Ugo
>
>
Try this:

function checkLogin(funarg) {
      if (user == null) {
           login();
           this[funarg]();
      }
}

funarg is just the string "checkout", to get to the checkout() function 
you need to dereference the global scope object (this). In JavaScript, 
using the [] operator with a string argument behaves the same as using 
the dot operator. However, the dot operator requires a literal 
identifier. If you want to use a variable (as in this case) then you 
must use the [] operator.

Regards,

Chris


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Mime
View raw message