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

**URL:** <https://discuss.rubyonrails.org/t/two-rjs-visual-effects-will-happen-at-the-same-time/51875>\
**Category:** rubyonrails-talk\
**Created:** [May 24, 2010, 1:26pm UTC](https://discuss.rubyonrails.org/t/two-rjs-visual-effects-will-happen-at-the-same-time/51875 "2010-05-24T13:26:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [May 24, 2010, 1:26pm UTC](https://discuss.rubyonrails.org/t/two-rjs-visual-effects-will-happen-at-the-same-time/51875/1 "2010-05-24T13: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:

&nbsp;&nbsp;page[:vote\_score].visual\_effect :highlight, :startcolor =\> '#ffffff', :endcolor =\> '#ffcccc'

&nbsp;&nbsp;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:** ![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:** [May 24, 2010, 2:47pm UTC](https://discuss.rubyonrails.org/t/two-rjs-visual-effects-will-happen-at-the-same-time/51875/2 "2010-05-24T14:47:07Z")

</div>

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:** ![pepe1](https://avatars.discourse-cdn.com/v4/letter/p/dec6dc/32.png) [@pepe1](https://discuss.rubyonrails.org/u/pepe1)\
**Post date:** [May 25, 2010, 2:37pm UTC](https://discuss.rubyonrails.org/t/two-rjs-visual-effects-will-happen-at-the-same-time/51875/3 "2010-05-25T14:37:09Z")

</div>

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