On your download link, apply an onclick handler as well as a href- the onclick can clear your on-screen shopping cart. When is the on-screen list being loaded? at page load, ie: the rest of the site isn't ajax based? Or does the cart remain onscreen at all times with no refresh.
<a href="downloadlink.php" onclick="clearCart();return true;"> (inline handlers are bad) This will cause the cart to clear, then the user will navigate to downloadlink.php. If you didn't want them to download, you could return false. If you attach the event with Event.Observe you have to use Event.Stop(e) though Hope this helps Gareth On 3/20/07, Walter Lee Davis <[EMAIL PROTECTED]> wrote: > > > I have a shopping cart on a page that gathers files for download. As > the user browses around the various nested folders, she can add things > to the cart, remove single items from the cart, and empty the entire > cart. At any time, she can also download the entire cart contents as a > Zip archive. > > I am managing that download using a PHP script that forces the > file-type, and thus all I do is link to a real file > (download.php?cart=N) from my page. The last step of the download > script is to empty out the cart in the database. But the list on screen > remains the same until the visitor navigates to another folder, at > which point it refreshes and declares itself empty. Which is kind of > jarring to the user. > > I tried applying a periodic updater to the cart div, and that did work, > but it also killed the other events I had registered inside that div > (the individual files' remove me buttons). It also issued a request > every five seconds, which seems extreme. > > I am experimenting with just setting a delay after the click and > checking the cart again, but that seems fragile, since I don't know how > long it might take for the server to respond with the files. If I check > before it's done, the cart will be the same (since the download hasn't > started yet and the script returned true) and if I wait too long, it > will be jarring for the user. > > Any suggestions? I can't show any code, it's all hidden inside an HTTPS > site. I could do some extractions, I guess, but I am hoping someone may > have done this before and have a bright idea or two. > > Thanks, > > Walter > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
