Hi, Is there a way to redirect the page through a ajax request. I tried using link_to_remote tag as the logout link on a page and used the ''redirect_to index'' in the called method. But I get the whole page in the request.reponseText as normal text and the browser page doesn''t change. Has anyone implemented this succesfully.? TIA ~Shishir --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Shishir Srivastava wrote:> Is there a way to redirect the page through a ajax request. I tried > using link_to_remote tag as the logout link on a page and used the > ''redirect_to index'' in the called method. But I get the whole page in > the request.reponseText as normal text and the browser page doesn''t > change.Just send JS that sets the window.location: render :update do |rjs| rjs << "window.location = #{ url_for something };" end I wrote ''rjs'' where everyone else writes ''page'' because that was a bad idea for a variable name. There are way too many variables out there called ''page''! -- Phlip http://www.oreilly.com/catalog/9780596510657/ ^ assert_xpath --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> Just send JS that sets the window.location: > > render :update do |rjs| > rjs << "window.location = #{ url_for something };"url_for(something).inspect, for free quotes and escapes! -- Phlip --~--~---------~--~----~------------~-------~--~----~ 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 4 Oct 2007, at 16:39, Phlip wrote:> >> Just send JS that sets the window.location: >> >> render :update do |rjs| >> rjs << "window.location = #{ url_for something };" > > url_for(something).inspect, for free quotes and escapes! >page.redirect_to will do all that for you Fred --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
a bit confused.. 1. render :update do |rjs| rjs << "window.location = #{ url_for something };" end 2. page.redirect_to which one of these is correct...or both of them are..?? ~Shishir On Oct 4, 9:00 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 4 Oct 2007, at 16:39, Phlip wrote: > > > > >> Just send JS that sets the window.location: > > >> render :update do |rjs| > >> rjs << "window.location = #{ url_for something };" > > > url_for(something).inspect, for free quotes and escapes! > > page.redirect_to will do all that for you > > Fred--~--~---------~--~----~------------~-------~--~----~ 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 10/4/07, Shishir Srivastava <shishir.srivastava-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > a bit confused.. > > 1. render :update do |rjs| > rjs << "window.location = #{ url_for something };" > end > > 2. page.redirect_to > > which one of these is correct...or both of them are..??They both are. #2 generates the same javascript as is shown in #1. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
unfotunately am getting this error NameError in LoginController#logout </h1> <pre>undefined local variable or method `page'' for #<LoginController:0x7f2950c0></pre> <p><code>RAILS_ROOT: script/../config/..</code></p> i''ve added it like this in my LoginController#logout method def logout session[:sess].sign_out page.redirect_to "index" end where ''index'' is my target page ~Shishir On Oct 5, 1:30 am, "Bob Showalter" <showa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 10/4/07, Shishir Srivastava <shishir.srivast...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > a bit confused.. > > > 1. render :update do |rjs| > > rjs << "window.location = #{ url_for something };" > > end > > > 2. page.redirect_to > > > which one of these is correct...or both of them are..?? > > They both are. #2 generates the same javascript as is shown in #1.--~--~---------~--~----~------------~-------~--~----~ 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 4 Oct 2007, at 21:55, Shishir Srivastava wrote:> > unfotunately am getting this error > > NameError > in LoginController#logout > </h1> > <pre>undefined local variable or method `page'' for > #<LoginController:0x7f2950c0></pre> > <p><code>RAILS_ROOT: script/../config/..</code></p> > > i''ve added it like this in my LoginController#logout method > > def logout > session[:sess].sign_out > page.redirect_to "index" > endRead up on rjs. page is the name usually given to the instance of javascript generator you use. If you have an rjs template it will be defined in there. If you have a render :update then it is the thing that is yielded to the block. Either plonk it in logout.rjs or do some pike render :update do |page| ... end Fred> where ''index'' is my target page > > ~Shishir > > On Oct 5, 1:30 am, "Bob Showalter" <showa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> On 10/4/07, Shishir Srivastava <shishir.srivast...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >> >> >>> a bit confused.. >> >>> 1. render :update do |rjs| >>> rjs << "window.location = #{ url_for something };" >>> end >> >>> 2. page.redirect_to >> >>> which one of these is correct...or both of them are..?? >> >> They both are. #2 generates the same javascript as is shown in #1. > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---