# Sequential "page." commands in a js.rjs file?

**URL:** <https://www.ruby-forum.com/t/sequential-page-commands-in-a-js-rjs-file/157816>\
**Category:** Rails\
**Created:** [January 15, 2009, 3:27pm UTC](https://www.ruby-forum.com/t/sequential-page-commands-in-a-js-rjs-file/157816 "2009-01-15T15:27:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cmaxvv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/85f322/32.png) [@cmaxvv](https://www.ruby-forum.com/u/cmaxvv)\
**Post date:** [January 15, 2009, 3:27pm UTC](https://www.ruby-forum.com/t/sequential-page-commands-in-a-js-rjs-file/157816/1 "2009-01-15T15:27:18Z")

</div>

After the (remote) delete action for my lesson\_categories controller i  
fall through to this js.rjs file:

page.visual\_effect :fade, “lesson\_category\_#{@lesson\_category.id}”,  
:duration =\> 1  
page.remove “lesson\_category\_#{@lesson\_category.id}”

The problem, though, is that the visual effect is initiated, then the  
remove is initiated, before the visual effect is finished, so that the  
visual effect doesn’t get a chance to be seen. Is there a way to set  
this up so that the remove isn’t called until the visual effect  
finishes? Normally i’d look for a callback but i can’t work out how to  
do it.

thanks  
max

---

<div class="post-metadata">

**Author:** ![cmaxvv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/85f322/32.png) [@cmaxvv](https://www.ruby-forum.com/u/cmaxvv)\
**Post date:** [January 15, 2009, 3:50pm UTC](https://www.ruby-forum.com/t/sequential-page-commands-in-a-js-rjs-file/157816/2 "2009-01-15T15:50:41Z")

</div>

On 15 Jan 2009, at 14:27, Max W. wrote:

> visual effect doesn’t get a chance to be seen. Is there a way to set  
> this up so that the remove isn’t called until the visual effect  
> finishes? Normally i’d look for a callback but i can’t work out how  
> to  
> do it.

scriptaculous effects can have a bunch of options, including  
afterFinish, but I think you’ll need to write the javascript out by  
hand to use those.#

Fred
