Ruby Quicktips Logo

Ruby Quicktips

Random Ruby and Rails tips.
This blog is dedicated to deliver short, interesting and practical tidbits of the Ruby language and Ruby on Rails framework. Read more...

Your submissions are more than welcome!
Dec 21 ’10

Delay your Javascript execution

There’s a Prototype helper method called delay, so you can more precisely say when something will happen.
For example, you can do stuff like this inside your RJS files:

page["old_element"].visual_effect :blind_up, :duration => 0.5

page.delay(0.5) do
  page.replace :old_element, :partial => "new_element"
  page["new_element"].visual_effect :blind_down
end

Check out the delay method.

3 notes 0 comments

  1. atm09td reblogged this from rubyquicktips
  2. rubyquicktips posted this

Comments

You can use HTML tags for formatting. Wrap code in <code> tags and multiple lines of code in <pre><code> tags.

blog comments powered by Disqus