MrBanabas-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org
2007-Mar-06 16:00 UTC
Ajax Call redirect to a full page refresh
Hi, Let s assume my controller gets a ajax call... I will start the process to to the appropriate actions... During the process I discover that the changes are too complex and I cannot provide the user the response with just an ajax response... instead I would need a full page fresh... Unfortunelty, I ve got no idea how to solve this... :-( Thanks a lot in advance... - Volker --~--~---------~--~----~------------~-------~--~----~ 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 Mar 6, 10:00 am, "MrBana...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org" <MrBana...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> Hi, > > Let s assume my controller gets a ajax call... I will start the > process to to the appropriate actions... > During the process I discover that the changes are too complex and I > cannot provide the user the response with just an ajax response... > instead I would need a full page fresh... > > Unfortunelty, I ve got no idea how to solve this... :-( > > Thanks a lot in advance... > > - > Volker------- def my_action if changes_are_too_complex redirect_to :action => ''show'' ... else # auto-render my_action.rjs template if its there end end If you don''t do anything, you''ll get the template automatically. If you do a redirect, the auto template will get skipped. -- Wes --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> Let s assume my controller gets a ajax call... During the process I discover that the changes are too complex and I > cannot provide the user the response with just an ajax response...instead I would need a full page fresh... >since you have in "page" the object representing your javascript document, you could just send a client-side redirect to that object and the browser would do the rest. regards, javier ramirez -- -------- Estamos de estreno... si necesitas llevar el control de tus gastos visita http://www.gastosgem.com !!Es gratis!! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Unfortunately, I don''t believe that will work. From what I''ve seen, what Wes'' solution will do is redraw the entire page inside of the element specified in Ajax.Update, leading to a very odd looking site-in-site effect. The best way I could think of doing it was to send RJS back that does a simple "document.location = page_url", forcing the browser to reload the page from scratch. Jason On 3/6/07, wesgarrison <wes.garrison-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On Mar 6, 10:00 am, "MrBana...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org" > <MrBana...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > > Hi, > > > > Let s assume my controller gets a ajax call... I will start the > > process to to the appropriate actions... > > During the process I discover that the changes are too complex and I > > cannot provide the user the response with just an ajax response... > > instead I would need a full page fresh... > > > > Unfortunelty, I ve got no idea how to solve this... :-( > > > > Thanks a lot in advance... > > > > - > > Volker > > ------- > def my_action > if changes_are_too_complex > redirect_to :action => ''show'' ... > else > # auto-render my_action.rjs template if its there > end > end > > If you don''t do anything, you''ll get the template automatically. If > you do a redirect, the auto template will get skipped. > > -- Wes > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> Unfortunately, I don''t believe that will work. From what I''ve seen, > what Wes'' solution will do is redraw the entire page inside of the > element specified in Ajax.Update, leading to a very odd looking > site-in-site effect. The best way I could think of doing it was to > send RJS back that does a simple "document.location = page_url", > forcing the browser to reload the page from scratch.if you are not using any "update" parameter when invoking ajax (and if you use update you can change that easily), you can directly do page.redirect_to whatever you can do that in the rjs or directly on the controller by using render :update. Behind the scenes it will do domething pretty similar to what you propose, which is changing window.location.href. The advantage is you can use the parameters of redirect_to and you don''t need to implement anything at the server side regards, j -------- Estamos de estreno... si necesitas llevar el control de tus gastos visita http://www.gastosgem.com !!Es gratis!! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I would do something like def my_action if changes_are_too_complex render :update do |page| page.redirect_to :action => "show" end end end Also with the default my_action.rjs template (as indicated above). -carl On 3/6/07, wesgarrison <wes.garrison-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > On Mar 6, 10:00 am, "MrBana...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org" > <MrBana...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > > Hi, > > > > Let s assume my controller gets a ajax call... I will start the > > process to to the appropriate actions... > > During the process I discover that the changes are too complex and I > > cannot provide the user the response with just an ajax response... > > instead I would need a full page fresh... > > > > Unfortunelty, I ve got no idea how to solve this... :-( > > > > Thanks a lot in advance... > > > > - > > Volker > > ------- > def my_action > if changes_are_too_complex > redirect_to :action => ''show'' ... > else > # auto-render my_action.rjs template if its there > end > end > > If you don''t do anything, you''ll get the template automatically. If > you do a redirect, the auto template will get skipped. > > -- Wes > > > > > >-- EPA Rating: 3000 Lines of Code / Gallon (of coffee) --~--~---------~--~----~------------~-------~--~----~ 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 Mar 6, 10:50 am, "Jason Roelofs" <jameskil...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Unfortunately, I don''t believe that will work. From what I''ve seen, what > Wes'' solution will do is redraw the entire page inside of the element > specified in Ajax.Update, leading to a very odd looking site-in-site effect. > > The best way I could think of doing it was to send RJS back that does a > simple "document.location = page_url", forcing the browser to reload the > page from scratch. > > Jason > > On 3/6/07, wesgarrison <wes.garri...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > On Mar 6, 10:00 am, "MrBana...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org" > > <MrBana...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > > > Hi, > > > > Let s assume my controller gets a ajax call... I will start the > > > process to to the appropriate actions... > > > During the process I discover that the changes are too complex and I > > > cannot provide the user the response with just an ajax response... > > > instead I would need a full page fresh... > > > > Unfortunelty, I ve got no idea how to solve this... :-( > > > > Thanks a lot in advance... > > > > - > > > Volker > > > ------- > > def my_action > > if changes_are_too_complex > > redirect_to :action => ''show'' ... > > else > > # auto-render my_action.rjs template if its there > > end > > end > > > If you don''t do anything, you''ll get the template automatically. If > > you do a redirect, the auto template will get skipped. > > > -- WesI could''a sworn that I''d used redirect_to instead of page.redirect_to. Anyway, you can do your processing to determine what "too complex" means, then either render a redirect, render some js in the controller, or pass it to a .rjs template. -- Wes --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
My guess is that you just want cause the entire page to refresh.... so here is another option... def my_action #do stuff if changes_are_too_complex render :update do |page| page.replace_html ''message_to_user_div'', ''<strong>Reloading Page...</strong>'' page.call ''location.reload'' end else #do other stuff end end MrBanabas-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org wrote:> Hi, > > Let s assume my controller gets a ajax call... I will start the > process to to the appropriate actions... > During the process I discover that the changes are too complex and I > cannot provide the user the response with just an ajax response... > instead I would need a full page fresh... > > Unfortunelty, I ve got no idea how to solve this... :-( > > Thanks a lot in advance... > > - > Volker > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---