Dear Richard,

amazing :-)

thanks a lot.
They should update the wiki with this tip.

On 21 Lug, 14:23, Richard Quadling <rquadl...@gmail.com> wrote:
> On 21 July 2010 13:10, Richard Quadling <rquadl...@gmail.com> wrote:
>
>
>
> > On 20 July 2010 23:37, Febo <ilpuccio.f...@gmail.com> wrote:
> >> Thanks Richard and Ralph,
>
> >> I'm studing the code but my feeling is that Effect.toggle can't handle
> >> the Object which is always passed by Effect.multiple as last parameter
> >> or let's say "effect".
>
> >> I don't know very much JavaScript, so I came up with this solution.
> >> I added a funciton to public/javascripts/prototype.js
>
> >>  Toggle: function(element, options) {
> >>    element = $(element);
> >>    effect = ($(options)['effect'] || 'appear').toLowerCase();
> >>    Effect.toggle(element, effect, options);
> >>  }
>
> >> calling the multiple function:
>
> >> Effect.multiple(['id_1','id_2',...,'id_n'], Effect.Toggle,
> >> {'effect':'appear'})
>
> >> I tested the curry but without success, perhaps I'm not so good in JS
> >> so I didn't catch the concept of curry.
> >> If you have a better solution, let me know.
>
> >> The problem with the class solution is that I have a table and I want
> >> to hide some rows of this table, I set the class of each row to odd/
> >> even for zebra colouring.
>
> >> On 20 Lug, 19:08, Richard Quadling <rquadl...@gmail.com> wrote:
> >>> On 20 July 2010 17:59, Ralph Brickley <i...@topsoftweb.com> wrote:
>
> >>> > This is a revelation to me. I didn't know Effect had a multiple. Also, 
> >>> > what is curry?
>
> >>> > My solution has been to tag those elements with a class, ie <div 
> >>> > class="effects">
>
> >>> > Then use $$('effects') to get each item and all effects... On each
>
> >>> > Sent from my iPhone
>
> >>> > On Jul 20, 2010, at 9:08 AM, Richard Quadling <rquadl...@gmail.com> 
> >>> > wrote:
>
> >>> >> On 20 July 2010 15:55, Febo <ilpuccio.f...@gmail.com> wrote:
> >>> >>> Hello,
> >>> >>> I'd like to use the toggle effect on multiple object at the same time
> >>> >>> I tried with
>
> >>> >>> Effect.multiple(['id_1','id_2','id_n'], Effect.toggle)
>
> >>> >>> but it doesn't work, also I don't know where/how to pass the 'appear'
> >>> >>> parameter
>
> >>> >>> I'm used to call toggle in this way:
> >>> >>> Effect.toggle('my_id_of_interest','appear')
>
> >>> >> At a guess, you need to curry() [1] the parameter.
>
> >>> >> So, can you try ...
>
> >>> >> Effect.multiple(['id_1','id_2','id_n'], Effect.toggle.curry('appear'));
>
> >>> >> Regards,
>
> >>> >> Richard.
>
> >>> >> [1]http://api.prototypejs.org/language/function/prototype/curry/
>
> >>> "Curries (burns in) arguments to a function, returning a new function
> >>> that when called with call the original passing in the curried
> >>> arguments (along with any new ones)"
>
> >>> The linkhttp://api.prototypejs.org/language/function/prototype/curry/
> >>> is the documentation for curry.
>
> >>> So, Effect.toggle.curry('appear') returns a new function which, when
> >>> called, will call the Effect.toggle function with  'appear' as the
> >>> first parameter, along with any other parameters supplied by the
> >>> Effect.multiple() function.
>
> >>> Is it the same as $$('effects').invoke('toggle', 'appear');
>
> >>> Hmm. On the surface, probably yes. But I'm not an expert here.
>
> >>> One difference is that Effect.multiple allows you to supply any ids.
>
> >>> I suppose ...
>
> >>> Effect.multiple($$('effects'), Effect.toggle.curry('appear'));
>
> >>> could also be a similar approach.
>
> > Ah. Yes. toggle requires the element first. Using curry() puts the
> > parameters the wrong way round.
>
> > Sorry about that.
>
> > So...
>
> > Effect.multiple
> >  (
> >  ['id1', 'id2'],
> >  function(el) { Effect.toggle(el, 'appear');}
> >  );
>
> > maybe.
>
> Onhttp://script.aculo.us/, opening the console command line (using
> Google Chrome).
>
> Entered
>
> Effect.multiple(['header','ninja'],function(el){Effect.toggle(el, 'appear');})
>
> and the 2 elements fade out.
>
> Repeat the all and they fade back in.
>
> So this looks like a winner.
>
> In essence the curry() call was doing ...
>
> Effect.multiple(['header','ninja'],function(el){Effect.toggle('appear',el);})
>
> which is why it wasn't working for you. Sorry again.
>
> Regards,
>
> Richard.

-- 
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 prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.

Reply via email to