Hey there - I''ve got a problem I''ve been trying to find a solution to. I''ve got a page which contains a list of prices which are gathered from various websites - however it takes a while for the prices to be collected, so the page takes a while to load ( up to 30 seconds ). I''m looking for a technique for the page to load the elements as they become available. I tried this, but the result isn''t passed to the browser until it''s complete: render :update do |page| ## Set all the prices to spinners. for shop in Shop.find(:all) do page.replace_html( "shop_#{shop.id}", "<span class=''label''>#{shop.name}</span><span class=''formw''><img src=''/ images/spinner.gif''/></span>") price = shop.get_pricing(@item) page.replace_html( "shop_#{shop.id}", :partial => "price", :object => price ) unless price.nil? end end I''ve been thinking of setting a status of the price to "loading", then having an observer on the page to check every few seconds, but I don''t much like the idea of a page asking the server for an update every few seconds once the page is complete. So, is it possible to alter the observer to stop observing once the elements are all loaded? Or is there some much more elegant way to achieve this? Cheers, Dan --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> Or is there some much more elegant way to achieve this? >..if you load some url in an iframe, it doesn''t stop the initial parent-page from loading (ie, it won''t take 30 seconds to load), and stops asking for requests once the iframe is loaded. i found it works great on my app...maybe worth checking out in your case -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 15 Jul 2007, at 09:23, Dan Milne wrote:> I''ve been thinking of setting a status of the price to "loading", > then having an observer on the page to check every few seconds, but I > don''t much like the idea of a page asking the server for an update > every few seconds once the page is complete. So, is it possible to > alter the observer to stop observing once the elements are all loaded?Use a Javascript Event observer on window load (or document ready if you use lowpro) to trigger the loading of each individual shop price. I''m guessing requesting the price of an individual shop doesn''t take 30 seconds. It would involve some handwritten javascript, but it will surely pay off in the end. Best regards Peter De Berdt --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks for that - I''ll give those methods a shot. Cheers, Dan On 15/07/2007, at 19:21 , Peter De Berdt wrote:> > On 15 Jul 2007, at 09:23, Dan Milne wrote: > >> I''ve been thinking of setting a status of the price to "loading", >> then having an observer on the page to check every few seconds, but I >> don''t much like the idea of a page asking the server for an update >> every few seconds once the page is complete. So, is it possible to >> alter the observer to stop observing once the elements are all >> loaded? > > Use a Javascript Event observer on window load (or document ready > if you use lowpro) to trigger the loading of each individual shop > price. I''m guessing requesting the price of an individual shop > doesn''t take 30 seconds. It would involve some handwritten > javascript, but it will surely pay off in the end. > > > Best regards > > Peter De Berdt > > > >-- Dan Milne --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---