Mar
1
One of the coolest things I ran across in RJS was the delay method. This delay method will do just that and delay a number of seconds. So lets say you need to highlight something that was just added to the page after the user submits it. I would like it to add to the page then wait 1 second and then highlight. The following is the code for that.
1 2 3 4 5 6 7 | render :update do |page| page.html_replace 'testdiv', params[:the_text_added] page.delay(1) do page.visual_effect :highlight, 'testdiv', :duration => 2 end end |
Cool huh? Try it out and see what you can do with delay()!
Need more help with rails? Here is a great book that i recommend for all new and old rails developers: Beginning Ruby: From Novice to Professional



Leave A Comment!