You can rewrite your code as ;
var i = 0;
forEach(togglers, function(e) { e.stretcher = stretchers[i]; i++; });


On 8/4/06, troels knak-nielsen <[EMAIL PROTECTED]> wrote:
> I asked the same question recently:
> http://groups.google.com/group/mochikit/browse_thread/thread/caa986a88bbee128/d046b70967e7001f#d046b70967e7001f
>
> On 8/4/06, bartb <[EMAIL PROTECTED]> wrote:
> >
> > Hi,
> >
> > I am porting my code from prototype to MK and also try to apply FP as
> > much as I can. But, I'm a bit stuck... Is there a way to access some
> > index/loop variable in a forEach?
> >
> > This is the code I want to change:
> >
> > >> togglers = getElementsByTagAndClassName('a', 'toggler') //a's where I 
> > >> click on
> > >> stretchers = getElementsByTagAndClassName('div', 'stretcher') //div's 
> > >> that need toggling
> > >> for (var i=0; i<togglers.length; i++ ) { togglers[i].stretcher = 
> > >> stretchers[i] }
> > ...
> >
> > When I change the for loop into a forEach, I loose the loop i variable
> > which I need to access the other variable elements.
> > >> forEach(togglers, function(e) { e.stretcher = stretchers[i] } )
> >
> > Or is there an other function/way to do this in Mochi?
> >
> > Thanks, Bart
> >
> >
> > > >
> >
>
>
> --
> troels
>


-- 
troels

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"MochiKit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/mochikit
-~----------~----~----~----~------~----~------~--~---

Reply via email to