# Rjs problems

**URL:** <https://www.ruby-forum.com/t/rjs-problems/95675>\
**Category:** Rails\
**Created:** [January 19, 2006, 9:08am UTC](https://www.ruby-forum.com/t/rjs-problems/95675 "2006-01-19T09:08:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![carlwenrich](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/7feea3/32.png) [@carlwenrich](https://www.ruby-forum.com/u/carlwenrich)\
**Post date:** [January 19, 2006, 9:08am UTC](https://www.ruby-forum.com/t/rjs-problems/95675/1 "2006-01-19T09:08:49Z")

</div>

Hi,

I am having trouble with rjs templates. Basically I want the item\_div  
to fade if its already open and then display the new item that the  
user selected with the visual effect: appear. The code below causes  
the browser (firefox on osx) to open the div and then close it again  
as soon as it is open:

page.visual\_effect :fade, ‘item\_div’, :duration =\> 0.5  
page.replace\_html ‘item\_div’, :partial =\> ‘edit’  
page.visual\_effect :appear, ‘item\_div’, :duration =\> 0.5

Does anyone have any ideas or can anyone point me to some  
documentation that explains this?

Just to check that I wasn’t going insane the code below works as I would  
expect:

page.hide ‘item\_div’  
page.replace\_html ‘item\_div’, :partial =\> ‘edit’  
page.visual\_effect :appear, ‘item\_div’, :duration =\> 0.5

Thanks for your help,  
Carl.

–  
Carl W.  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![carlwenrich](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/7feea3/32.png) [@carlwenrich](https://www.ruby-forum.com/u/carlwenrich)\
**Post date:** [January 19, 2006, 10:27am UTC](https://www.ruby-forum.com/t/rjs-problems/95675/2 "2006-01-19T10:27:10Z")

</div>

visual\_effect doesn’t block, so execution of JavaScript code doesn’t  
pause until the visual effect is over.

You need to use the visual effect callbacks to achieve this (currently  
there’s no direct support in Rails for them (you probably need  
to write JavaScript manually for this).

-Thomas

Am 19.01.2006 um 08:31 schrieb Carl W.:
