On Thu, Jan 6, 2011 at 18:42, jraulperez <[email protected]>wrote:

>
> Hi
>
> Sorry because the subject it is not very descriptive... but I didn't know
> how to explay my "problem". So, I'm gonna do a little application to show
> what I'm trying to do, you can see it here (very simple):
> http://tinyurl.com/2wmp2gs
>
> So, once you have seen the application, it is normal that, "i" it is
> keeping
> the last value when it fires the event execute on diferent buttons?
>
> I'm using my experience about other languages to programme in qooxdoo, and
> maybe that is wrong...
>

Yup, it's wrong. :-) What's happening is that the value of i is changing,
and by the time your listener gets around to running, it's been incremented
to 5. The value of names[5] is printed regardless of which button was
pressed.

Here's one possible solution. In this example, a helper function, with its
own local variable i (the parameter) returns a function that has bound via a
closure (a JavaScript concept very worth learning about) the parameter value
to the alert message instead of the global i that is changing through the
loop.

*http://tinyurl.com/3ym5v8p*

Derrell
------------------------------------------------------------------------------
Gaining the trust of online customers is vital for the success of any company
that requires sensitive data to be transmitted over the Web.   Learn how to 
best implement a security strategy that keeps consumers' information secure 
and instills the confidence they need to proceed with transactions.
http://p.sf.net/sfu/oracle-sfdevnl 
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to