I''ve got a form on my page, and when the user submits it, sometimes I''d like to update an element on my page, and sometimes I''d like to redirect the browser to another url entirely. However if I do redirect_to, it just updates the element with the results of the redirect. Is it possible to do what I want, or will I need to use RJS to do this? Pat
you don''t have to use RJS, but RJS is probably the simplest way. rjs ex: page.redirect_to :controller => ..., :action => ..., ... On 4/1/06, Pat Maddox <pergesu@gmail.com> wrote:> > I''ve got a form on my page, and when the user submits it, sometimes > I''d like to update an element on my page, and sometimes I''d like to > redirect the browser to another url entirely. However if I do > redirect_to, it just updates the element with the results of the > redirect. Is it possible to do what I want, or will I need to use RJS > to do this? > > Pat > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060401/1e0e782a/attachment.html
Yeah I did some googling, and found that I could put this in the controller: render :update do |page| page.redirect_to home_url end However when I do that, the text "window.location.ref=...." shows up on the page. I don''t want the user to see that...maybe I can have it show a custom message when it performs the action instead or something? Pat On 4/1/06, Chris Hall <christopher.k.hall@gmail.com> wrote:> you don''t have to use RJS, but RJS is probably the simplest way. > > rjs ex: > > page.redirect_to :controller => ..., :action => ..., ... > > > On 4/1/06, Pat Maddox <pergesu@gmail.com> wrote: > > > I''ve got a form on my page, and when the user submits it, sometimes > I''d like to update an element on my page, and sometimes I''d like to > redirect the browser to another url entirely. However if I do > redirect_to, it just updates the element with the results of the > redirect. Is it possible to do what I want, or will I need to use RJS > to do this? > > Pat > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >
Okay once I took the update out of the form_remote_tag call, and just used page.replace_html inside my controller, everything works nicely and doesn''t show the JS in the page anymore. Thanks Chris! Pat On 4/1/06, Pat Maddox <pergesu@gmail.com> wrote:> Yeah I did some googling, and found that I could put this in the controller: > > render :update do |page| > page.redirect_to home_url > end > > However when I do that, the text "window.location.ref=...." shows up > on the page. I don''t want the user to see that...maybe I can have it > show a custom message when it performs the action instead or > something? > > Pat > > On 4/1/06, Chris Hall <christopher.k.hall@gmail.com> wrote: > > you don''t have to use RJS, but RJS is probably the simplest way. > > > > rjs ex: > > > > page.redirect_to :controller => ..., :action => ..., ... > > > > > > On 4/1/06, Pat Maddox <pergesu@gmail.com> wrote: > > > > > I''ve got a form on my page, and when the user submits it, sometimes > > I''d like to update an element on my page, and sometimes I''d like to > > redirect the browser to another url entirely. However if I do > > redirect_to, it just updates the element with the results of the > > redirect. Is it possible to do what I want, or will I need to use RJS > > to do this? > > > > Pat > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > >