Hi Edd,

> Just to confuse issues slightly, wouldn’t it be better to use #map
> instead of #each?

Why?  He isn't using the return value, so no need to create the return
array.

One concern in both cases, though, is whether Effect.SlideDown will be
bothered by the extra parameter provided by both #each and #map's
calls to the iterator.  According to the scripty docs, it expects the
element and an optional options object, whereas #each and #map will
pass it the element and the element's index in the array.  Oops. -
grin-

So perhaps better to replace

    .each(Effect.SlideDown);

...in the various examples with something more expicit:

    .each(function(elm) {
        Effect.SlideDown(elm);
    });

...or something like that.
--
T.J. Crowder
tj / crowder software / com
Independent Software Engineer, consulting services available


On Jan 15, 3:19 pm, redheat <[email protected]> wrote:
> TJ,
>
> Just to confuse issues slightly, wouldn’t it be better to use #map
> instead of #each?
>
> Edd
>
> P.S., I haven’t tested, so #map may not work.
>
>
>
> > If you know there will only be one and don't mind if the effect
> > applies to all of them if (for whatever reason) there's more than one,
> > Enumerable#each makes for a concise bit of code:
>
> > document.observe("dom:loaded", function() {
> >   $('editProducts').select('div.test').each(Effect.SlideDown);
>
> > });
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" 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/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to