Hi I have an index.rhtml which is the default view. I have a form that is loaded/opened using rjs. If the info does not save, I have ajax error_messages_for that shows the user what is wrong. This works nicely, however, if the info is correct and the records are saved, I would like to present the index page again. Ideally, I would just redirect_to :action => ''index'' in my view, but the call comes from a form_remote_for which does not like the redirect_to. So, what I am trying to do at the moment is to if saved render (:update) do |page| page.replace_html ''content'', :template => ''index'' end else render (:update) do |page| page.replace_html ''form'', :partial => ''form'' end end where content div is the div that receives @content_for_layout. I get rjs error html has no properties Element.update("content",null); Can anyone explain to me what is happening here, and/or how to fix it. regards Ivor --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi, Ivor Paul wrote:> Ideally, I would just redirect_to :action => ''index'' in > my view, but the call comes from a form_remote_for > which does not like the redirect_to.You can use page.redirect_to ... within your RJS. hth, Bill --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
add :update => "content" in your form_remote_for tag eg. <% form_remote_for(@object,:url => {:action => ''update''}, :update => "content") do |f| %> <% end %> and in your controller if saved render :template => ''index'' else render (:update) do |page| page.replace_html ''form'', :partial => ''form'' end end its working. -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.