How to serve JS with Rails
Let's say I want to queue up these JS calls, can this be done using Rails helpers?
render :update do |page|
page.replace_html replace_html 'notice', flash[:notice]
page.visual_effect :blind_down, "notice", :duration => 0.5
page.visual_effect :blind_up, "notice", :duration => 0.5
end
Thanks.
a source to share
Scenario effects have a parameter queue
that you can specify as a parameter visual_effect
. For instance,
render :update do |page|
page.replace_html replace_html 'notice', flash[:notice]
page.visual_effect :blind_down, "notice", :duration => 0.5, :queue => 'end'
page.visual_effect :blind_up, "notice", :duration => 0.5, :queue => 'end'
end
will queue two effects so that the blind effect does not start until the blind is extinguished.
See Effect Queues in the wiki script.aculo.us github for more information on how the queues work and what options you can give (e.g. one queue is used by default for this page, but you can define multiple queues if you want. so that different queues of effects run in parallel). :queue
can accept either a string (as above) or a hash, allowing you to customize more:
:queue => { :position => 'end', :scope => 'my_effect_queue' }
a source to share