RJS page.delay timing issues

Hi.

Has anyone ran into issues with the timing of page.delay. I have been
testing in firefox, for the most part, and it seems that there is no
reliability on when the page.delay timings kick in.

What happens is that sometimes it will work fine, and the countdown
looks great; other times it will just jump to the end and display
everything at once, other times it will be jerky. I’m on a pretty
powerful machine, so the javascript shouldn’t be causing system
slowdowns, from what I can tell…

Maybe I’m using it wrong?

info.rjs

  1. page.visual_effect :fade, 'Infoname', :duration => 0.5
    
  2. page.visual_effect :fade, 'InfoDescription', :duration => 0.5
    
  3. page.visual_effect :fade, 'InfoButton', :duratin => 0.5
    
  4. page.delay(1.0) do
    
  5.   page.insert_html :top, 'countdown', 'Info in..'
    
  6. end
    
  7. page.delay(2.0) do
    
  8.   page.insert_html :bottom, 'countdown', '3'
    
  9. end
    
  10. page.delay(2.3) do
    
  11.   page.insert_html :bottom, 'countdown', '.'
    
  12. end
    
  13. page.delay(2.6) do
    
  14.   page.insert_html :bottom, 'countdown', '.'
    
  15. end
    
  16. page.delay(3.0) do
    
  17.   page.insert_html :bottom, 'countdown', '2'
    
  18. end
    
  19. page.delay(3.3) do
    
  20.   page.insert_html :bottom, 'countdown', '.'
    
  21. end
    
  22. page.delay(3.6) do
    
  23.   page.insert_html :bottom, 'countdown', '.'
    
  24. end
    
  25. page.delay(4.0) do
    
  26.   page.insert_html :bottom, 'countdown', '1'
    
  27. end
    
  28. page.delay(4.5) do
    
  29.   page.replace_html 'countdown', '<div
    

id=“countdownGO”>GO!’
31. page.visual_effect :puff, ‘countdown’, :duration => 0.5
32. end
33. page.delay(5.0) do
34. page.visual_effect :fade, ‘profile-indicator’
35. page.replace_html ‘info’, :partial => ‘info/test’
36. end

Any ideas? Am I using the RJS template in a way it wasn’t designed, or
extremely inefficient, that would cause it to be so erratic?

Thank you for your help.

Justin C. wrote:

Hi.

Has anyone ran into issues with the timing of page.delay. I have been
testing in firefox, for the most part, and it seems that there is no
reliability on when the page.delay timings kick in.
SNIP
Thank you for your help.

Try sticking a , :queue => “end”
on the end of each of your page.somethingorother lines.

Anytime I’ve ever tried to do multiple things in one set of rendering,
this was needed in order to make it do what you would normally expect it
to do. If I understand it correctly, this just forces it to do it all
in the order that you have described it with your code.

best,
jp

On 11/18/06, Justin C. [email protected] wrote:

everything at once, other times it will be jerky. I’m on a pretty
powerful machine, so the javascript shouldn’t be causing system
slowdowns, from what I can tell…

Maybe I’m using it wrong?

You can’t rely on browser to launch timers in proper order.
I would schedule next event only after previous event executed:

page.delay 1

count 1

page.delay 1
# count 2
page.delay 1
# count 3
end
end
end

That is basics. For more advanced stuff you should get more familiar
with
Javascript and Prototype and write some component (e.g. CountdownTimer).

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs