Rails tip of the day: queueing multiple scriptaculous effects via rjs

You want to have multiple effects executed after each other? From a controller method using rjs? Using the naive way of calling them just one after the other results in strange flickering effects. The key to success is to use the effect queue parameter, which is very weakly documented. Here is an example:

page[@object].down(‘.star’).visual_effect :appear, :duration=>1.2, :queue=>’front’
page[@object].down(‘.star’).visual_effect :fade, :duration=>1.2, :queue=>’end’

The trick is the queue parameter. This way, first the appear effect is executed on the DOM object, and then fade. Omitting queue won’t work.

Leave a Reply