olivierdupuis-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Dec-28 16:18 UTC
Message to user while page loads
In my RoR project, I have an action that loads a ton of information than displays it to the user. When the user ask that resource, he has to wait a couple of seconds before something shows up. I''d like to give users a message while they are waiting. I first thought that this would be easy, but I was wrong. How can I render a view before processing the action and then render another view? Any help would be greatly appreciated. Thank you Olivier Dupuis --~--~---------~--~----~------------~-------~--~----~ 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 Dec 28, 2007, at 10:18 AM, olivierdupuis-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:> > In my RoR project, I have an action that loads a ton of information > than displays it to the user. When the user ask that resource, he has > to wait a couple of seconds before something shows up. I''d like to > give users a message while they are waiting. > > I first thought that this would be easy, but I was wrong. How can I > render a view before processing the action and then render another > view? > > Any help would be greatly appreciated. >In AQDWR v2 (Rails 1.2), there is this example: <% form_remote_tag(:url => {:action => ''iffy_function''}, :before => "Element.show(''spinner'');", :success => "show_results(xhr);", :failure => "show_error(xhr);", :complete => "Element.hide(''spinner'');") do %> Maybe this can get you started? Peace, Phillip --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
olivierdupuis-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Dec-28 16:46 UTC
Re: Message to user while page loads
I actually thought of using Ajax, since this seems to be the most obvious choice. The page would load, then I could send a xhr to the server and update a div with my results. The only problem is, I can''t find a way to call a xhr only once when the page is loaded, without the intervention of the user. When I look at the prototype library, the periodically_call_remote method comes closest to what I want. But the only option I have is the frequency at which the request should be made. That means the request would be made multiple time... Any idea of an ajax call I could use to do this? Thanks again Olivier On Dec 28, 11:35 am, Phillip Koebbe <phillipkoe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Dec 28, 2007, at 10:18 AM, olivierdup...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote: > > > > > In my RoR project, I have an action that loads a ton of information > > than displays it to the user. When the user ask that resource, he has > > to wait a couple of seconds before something shows up. I''d like to > > give users a message while they are waiting. > > > I first thought that this would be easy, but I was wrong. How can I > > render a view before processing the action and then render another > > view? > > > Any help would be greatly appreciated. > > In AQDWR v2 (Rails 1.2), there is this example: > > <% form_remote_tag(:url => {:action => ''iffy_function''}, > :before => "Element.show(''spinner'');", > :success => "show_results(xhr);", > :failure => "show_error(xhr);", > :complete => "Element.hide(''spinner'');") do %> > > Maybe this can get you started? > > Peace, > Phillip--~--~---------~--~----~------------~-------~--~----~ 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 Dec 28, 2007, at 10:46 AM, olivierdupuis-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:> > I actually thought of using Ajax, since this seems to be the most > obvious choice. The page would load, then I could send a xhr to the > server and update a div with my results. > > The only problem is, I can''t find a way to call a xhr only once when > the page is loaded, without the intervention of the user. When I look > at the prototype library, the periodically_call_remote method comes > closest to what I want. But the only option I have is the frequency > at which the request should be made. That means the request would be > made multiple time... > > Any idea of an ajax call I could use to do this? >I generally do something like this by outputting some Javascript at the end of the page, like <script type="text/javascript"> some_function_call(); </script> Then in your js file, have some_function_call make your xhr request. The more appropriate way to do this is to use window.onload, but then you''ve got to figure out where to make the assignment window.onload = some_function_call That''s why I often just put it at the end of the page. There is probably a more proper Rails/Prototype way to do it, but I haven''t yet dug that deep. Peace, Phillip --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---