# Consecutive event triggering in RJS

**URL:** <https://www.ruby-forum.com/t/consecutive-event-triggering-in-rjs/171129>\
**Category:** Rails\
**Created:** [June 26, 2009, 8:29pm UTC](https://www.ruby-forum.com/t/consecutive-event-triggering-in-rjs/171129 "2009-06-26T20:29:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![No\_BS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/779978/32.png) [@No\_BS](https://www.ruby-forum.com/u/No_BS)\
**Post date:** [June 26, 2009, 8:29pm UTC](https://www.ruby-forum.com/t/consecutive-event-triggering-in-rjs/171129/1 "2009-06-26T20:29:25Z")

</div>

I know I’ve actually done this before, but I’ve spent the past couple  
hours searching Google and my own code and have come up with nothing.

Does anyone know how to trigger events consecutively in RJS? For  
instance, if you have something like the following:

`
page.replace :some_div, render(:partial => “some_partial”)
page.visual_effect :fade, “some_element_in_partial”
`

The fade effect may not occur if the partial has not finished  
rendering when the fade effect is called, thereby leaving the  
“some\_element\_in\_partial” visible on the page.

I seem to remember having to create a ‘do’ block and nesting the  
effects, while passing in some sort of “serial\_event” option or  
something like that, but cannot remember exactly.

---

<div class="post-metadata">

**Author:** ![No\_BS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/779978/32.png) [@No\_BS](https://www.ruby-forum.com/u/No_BS)\
**Post date:** [June 26, 2009, 8:35pm UTC](https://www.ruby-forum.com/t/consecutive-event-triggering-in-rjs/171129/2 "2009-06-26T20:35:16Z")

</div>

If it’s prototype based, search for “queue”. At least for the visual  
effects, you assign it a queue and the position in the queue. You can  
probably wrap everything up in a queue.

For jquery, either chain them or put them into the “on complete”  
callbacks.
