Instead of running each() on each element to run the Effect take a look a
Effect.multiple()

http://madrobby.github.com/scriptaculous/effect-multiple/

it will do the heavy lifting for you and makes the code more readable

Jason Westbrook | T: 313-799-3770 | jwestbr...@gmail.com


On Wed, Jan 23, 2013 at 7:05 AM, Walter Lee Davis <wa...@wdstudio.com>wrote:

>
> On Jan 23, 2013, at 7:48 AM, Köd wrote:
>
> > Hi guys
> >
> > To get a full view of my problem, please read:
> http://stackoverflow.com/questions/14478903/script-aculo-us-toggle-appear-on-multiple-divs
> > _____________________________________________
> >
> > I have a simple question to ask you:
> > Is it possible to use effect.opacity as a toggle effect?
> >
> > The reason why I'm asking this is because when using effect.opacity the
> assigned function can be spammed, hence making the div appear/fade over and
> over. I was thinking that it might would be possible to do so by changing
> something in the scriptaculous.js or effects.js file.
> >
> >
> > If this is not possible, I would like to ask how you can use
> Effect.Toggle (appear) on multiple div's within an <a href> containing an
> onclick. An example:
> >
> > <li><a href="#" onclick="Effect.toggle('DIV1, DIV2, DIV3', 'appear');
> return false;"></a>
>
> It's going to be really hard to do this inline (I suppose it's possible,
> but not very readable) but if you create an observer function, then there
> should be a way to do this:
>
> var toggleMyItems = function(items){
>         $w(items).each(function(elm){
>                 var elm = $(elm);
>                 if(elm && ! elm.animating){
>                         elm['animating'] = true;
>                         Effect.toggle(
>                                 elm,
>                                 'appear', {
>                                         afterFinish: function(){
>                                                 elm.animating = false;
>                                         }
>                                 }
>                         );
>                 }
>         });
> });
>
> Then you could call that from inline:
> <a href="#" rel="DIV1 DIV2 DIV3" onclick="toggleMyItems(this.rel); return
> false;">Howdy</a>
>
> Or better, observe the click and do it elsewhere (separation of concerns):
>
> document.on('click', 'a.multi', function(evt, elm){
>         evt.stop();
>         toggleMyItems(elm.rel);
> });
>
> <a href="#" class="multi" rel="DIV1 DIV2 DIV3">Howdy</a>
>
> Walter
>
> >
> > Thanks.
> >
> > --
> > You received this message because you are subscribed to the Google
> Groups "Prototype & script.aculo.us" group.
> > To view this discussion on the web visit
> https://groups.google.com/d/msg/prototype-scriptaculous/-/_mWlqcRjEnIJ.
> > To post to this group, send email to
> prototype-scriptaculous@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.
>
> --
> 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-scriptaculous@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.
>
>

-- 
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-scriptaculous@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