How to load many slow items into a page?

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

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

Thanks for that - I'll give those methods a shot.

Cheers, Dan