# Two RJS visual effects will happen at the same time?

**URL:** <https://www.ruby-forum.com/t/two-rjs-visual-effects-will-happen-at-the-same-time/189097>\
**Category:** Rails\
**Created:** [May 24, 2010, 3:26pm UTC](https://www.ruby-forum.com/t/two-rjs-visual-effects-will-happen-at-the-same-time/189097 "2010-05-24T15:26:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![winterheat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7993a0/32.png) [@winterheat](https://www.ruby-forum.com/u/winterheat)\
**Post date:** [May 24, 2010, 3:26pm UTC](https://www.ruby-forum.com/t/two-rjs-visual-effects-will-happen-at-the-same-time/189097/1 "2010-05-24T15:26:54Z")

</div>

I was going to change the background of a div from white to red and then  
from red back to white, so this is used in an RJS file:

page[:vote\_score].visual\_effect :highlight, :startcolor =\> ‘#ffffff’,  
:endcolor =\> ‘#ffcccc’

page[:vote\_score].visual\_effect :highlight, :startcolor =\> ‘#ffcccc’,  
:endcolor =\> ‘#ffffff’

But looks like they happen at the same time, instead of one after  
another. Is there a way to make it happen one after another?

the Javascript sent to the browser is:

try {  
$(“vote\_score”).update(“Score 63”);  
$(“vote\_score”).visualEffect(“highlight”,  
{“endcolor”:"#ffcccc",“startcolor”:"#ffffff"});  
$(“vote\_score”).visualEffect(“highlight”,  
{“endcolor”:"#ffffff",“startcolor”:"#ffcccc"});  
} catch (e) { alert(‘RJS error:\n\n’ + e.toString());  
alert(’$(“vote\_score”).update(“Score  
63”);\n$(“vote\_score”).visualEffect(“highlight”,  
{“restorecolor”:"#ffcccc",“endcolor”:"#ffcccc",“startcolor”:"#ffffff"});\n$(“vote\_score”).visualEffect(“highlight”,  
{“endcolor”:"#ffffff",“startcolor”:"#ffcccc"});’); throw e }

---

<div class="post-metadata">

**Author:** ![winterheat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7993a0/32.png) [@winterheat](https://www.ruby-forum.com/u/winterheat)\
**Post date:** [May 24, 2010, 4:48pm UTC](https://www.ruby-forum.com/t/two-rjs-visual-effects-will-happen-at-the-same-time/189097/2 "2010-05-24T16:48:36Z")

</div>

On May 24, 2:26 pm, Jian L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> But looks like they happen at the same time, instead of one after  
> another. Is there a way to make it happen one after another?

The visual\_effect takes a queue option, read something like  
[http://script.aculo.us/docs/EffectQueues.html](http://script.aculo.us/docs/EffectQueues.html) to understand how effect  
queues work etc.

Fred

---

<div class="post-metadata">

**Author:** ![winterheat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7993a0/32.png) [@winterheat](https://www.ruby-forum.com/u/winterheat)\
**Post date:** [May 25, 2010, 4:38pm UTC](https://www.ruby-forum.com/t/two-rjs-visual-effects-will-happen-at-the-same-time/189097/3 "2010-05-25T16:38:46Z")

</div>

I found Ajax on Rails, from O’Reilly, to be an excellent book, if it’s  
any help.
