# Stack visual\_effect - possible?

**URL:** <https://discuss.rubyonrails.org/t/stack-visual-effect-possible/28681>\
**Category:** rubyonrails-talk\
**Created:** [April 28, 2008, 8:32pm UTC](https://discuss.rubyonrails.org/t/stack-visual-effect-possible/28681 "2008-04-28T20:32:23Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![RoRNoob](https://avatars.discourse-cdn.com/v4/letter/r/7bcc69/32.png) [@RoRNoob](https://discuss.rubyonrails.org/u/RoRNoob)\
**Post date:** [April 28, 2008, 8:32pm UTC](https://discuss.rubyonrails.org/t/stack-visual-effect-possible/28681/1 "2008-04-28T20:32:23Z")

</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:** ![11175](https://avatars.discourse-cdn.com/v4/letter/1/8edcca/32.png) [@11175](https://discuss.rubyonrails.org/u/11175)\
**Post date:** [April 29, 2008, 8:35am UTC](https://discuss.rubyonrails.org/t/stack-visual-effect-possible/28681/2 "2008-04-29T08: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:** ![Clever\_Neologism](https://avatars.discourse-cdn.com/v4/letter/c/e274bd/32.png) [@Clever\_Neologism](https://discuss.rubyonrails.org/u/Clever_Neologism)\
**Post date:** [April 29, 2008, 2:20pm UTC](https://discuss.rubyonrails.org/t/stack-visual-effect-possible/28681/3 "2008-04-29T14:20:07Z")

</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://avatars.discourse-cdn.com/v4/letter/r/7bcc69/32.png) [@RoRNoob](https://discuss.rubyonrails.org/u/RoRNoob)\
**Post date:** [May 2, 2008, 11:30pm UTC](https://discuss.rubyonrails.org/t/stack-visual-effect-possible/28681/4 "2008-05-02T23:30:15Z")

</div>

Thanks - I will give that a shot.

---

<div class="post-metadata">

**Author:** ![11175](https://avatars.discourse-cdn.com/v4/letter/1/8edcca/32.png) [@11175](https://discuss.rubyonrails.org/u/11175)\
**Post date:** [July 10, 2008, 5:07pm UTC](https://discuss.rubyonrails.org/t/stack-visual-effect-possible/28681/5 "2008-07-10T17:07:22Z")

</div>

Clever Neologism 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:** ![Frederick\_Cheung](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/frederick_cheung/32/3901_2.png) [@Frederick\_Cheung](https://discuss.rubyonrails.org/u/Frederick_Cheung)\
**Post date:** [July 11, 2008, 5:11pm UTC](https://discuss.rubyonrails.org/t/stack-visual-effect-possible/28681/6 "2008-07-11T17:11:17Z")

</div>

> Clever Neologism 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

---

<div class="post-metadata">

**Author:** ![11175](https://avatars.discourse-cdn.com/v4/letter/1/8edcca/32.png) [@11175](https://discuss.rubyonrails.org/u/11175)\
**Post date:** [July 11, 2008, 5:34pm UTC](https://discuss.rubyonrails.org/t/stack-visual-effect-possible/28681/7 "2008-07-11T17: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 🙂
