# Stack visual\_effect - possible?

**URL:** <https://www.ruby-forum.com/t/stack-visual-effect-possible/136099>\
**Category:** Rails\
**Created:** [April 28, 2008, 10:33pm UTC](https://www.ruby-forum.com/t/stack-visual-effect-possible/136099 "2008-04-28T22:33:07Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![rornoob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7bcc69/32.png) [@rornoob](https://www.ruby-forum.com/u/rornoob)\
**Post date:** [April 28, 2008, 10:33pm UTC](https://www.ruby-forum.com/t/stack-visual-effect-possible/136099/1 "2008-04-28T22:33:07Z")

</div>

Is it possible to apply two visual\_effect to the same DOM ID?

I can get it to work like this:

page[:current\_item].visual\_effect :highlight, :start\_color =\>  
“#fff”, :end\_color =\> “#000”  
page[:current\_item].visual\_effect :puff

But can I call it like this:

page[:current\_item].visual\_effect :EFFECT1, :EFFECT2

Thanks!

---

<div class="post-metadata">

**Author:** ![rornoob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7bcc69/32.png) [@rornoob](https://www.ruby-forum.com/u/rornoob)\
**Post date:** [April 29, 2008, 10:35am UTC](https://www.ruby-forum.com/t/stack-visual-effect-possible/136099/2 "2008-04-29T10:35:35Z")

</div>

most likely not a good idea.  
i had some problems doing things like that, because starting an effect  
stops the first one and leaves the item in some intermediate state.  
seems, there can be only one active effect at all.  
(maybe that’s fixed in newer versions, i didn’t try this for quite some  
time now)

---

<div class="post-metadata">

**Author:** ![rornoob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7bcc69/32.png) [@rornoob](https://www.ruby-forum.com/u/rornoob)\
**Post date:** [April 29, 2008, 4:20pm UTC](https://www.ruby-forum.com/t/stack-visual-effect-possible/136099/3 "2008-04-29T16:20:38Z")

</div>

If you want to run multiple sequential effects, use this rarely  
documented option:

visual\_effect(:highlight, “posts”, :duration =\> 0.5, :queue=\>‘end’)

If you want to run multiple effects simultaneously, you need to  
subclass an effect in the scriptaculous library and combine them  
programatically.

---

<div class="post-metadata">

**Author:** ![rornoob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7bcc69/32.png) [@rornoob](https://www.ruby-forum.com/u/rornoob)\
**Post date:** [May 3, 2008, 1:30am UTC](https://www.ruby-forum.com/t/stack-visual-effect-possible/136099/4 "2008-05-03T01:30:44Z")

</div>

Thanks - I will give that a shot.

---

<div class="post-metadata">

**Author:** ![rornoob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7bcc69/32.png) [@rornoob](https://www.ruby-forum.com/u/rornoob)\
**Post date:** [July 10, 2008, 7:07pm UTC](https://www.ruby-forum.com/t/stack-visual-effect-possible/136099/5 "2008-07-10T19:07:22Z")

</div>

Clever N. wrote:

> If you want to run multiple sequential effects, use this rarely  
> documented option:
> 
> visual\_effect(:highlight, “posts”, :duration =\> 0.5, :queue=\>‘end’)

How would that work? How can I have two visual effects when something  
is clicked?

\<%= content\_tag ‘div’, truncate(@linklog.notes, 40, “…”), :id =\>  
“initial#{@linklog.id}”, :onclick =\> visual\_effect(:toggle\_blind,  
“link\_body#{@linklog.id}”, :duration =\> 1.0, :queue=\>‘end’) %\>

---

<div class="post-metadata">

**Author:** ![rornoob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7bcc69/32.png) [@rornoob](https://www.ruby-forum.com/u/rornoob)\
**Post date:** [July 11, 2008, 7:34pm UTC](https://www.ruby-forum.com/t/stack-visual-effect-possible/136099/6 "2008-07-11T19:34:01Z")

</div>

> The rails javascript helpers can be handy but it’s important to  
> understand what they do.  
> visual\_effect(…) just spits out new Effect.Something($  
> (‘some\_id’), …)
> 
> so if you want 2 effects created then visual\_effect(…) + ‘;’ +  
> visual\_effect(…) will do the job.
> 
> Fred  
> Thanks, that was the exact answer I was looking for 🙂

---

<div class="post-metadata">

**Author:** ![rornoob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7bcc69/32.png) [@rornoob](https://www.ruby-forum.com/u/rornoob)\
**Post date:** [July 11, 2008, 7:12pm UTC](https://www.ruby-forum.com/t/stack-visual-effect-possible/136099/7 "2008-07-11T19:12:09Z")

</div>

On 10 Jul 2008, at 18:07, Joe P. wrote:

> Clever N. wrote:
> 
> > If you want to run multiple sequential effects, use this rarely  
> > documented option:
> > 
> > visual\_effect(:highlight, “posts”, :duration =\> 0.5, :queue=\>‘end’)
> 
> How would that work? How can I have two visual effects when something  
> is clicked?

There are two separate issues here: whether effects run in parallel,  
sequentially etc and then the business of actually creating an effect

> \<%= content\_tag ‘div’, truncate(@linklog.notes, 40, “…”), :id =\>  
> “initial#{@linklog.id}”, :onclick =\> visual\_effect(:toggle\_blind,  
> “link\_body#{@linklog.id}”, :duration =\> 1.0, :queue=\>‘end’) %\>

The rails javascript helpers can be handy but it’s important to  
understand what they do.  
visual\_effect(…) just spits out new Effect.Something($  
(‘some\_id’), …)

so if you want 2 effects created then visual\_effect(…) + ‘;’ +  
visual\_effect(…) will do the job.  
You will need to look into the queue options (or effect.parallel in  
friends) if you want to play around with which one happens first,  
whether they run sequentially or not etc…

Fred
