Christopher Berner
2007-Oct-20 17:11 UTC
How to update an iframe element with form_remote_tag?
I have a view with an iframe in it that contains a list of messages. I would like to update this list from a form in my view that I''ve created with form_remote_tag. My code is structured like this right now: #iframe_view.rhtml# <div id="message_list"> </div> #index.rhtml# <iframe id="iframe_messages" src=<%=url_for(:controller=>"messages", :action=>"iframe_view")%>> </iframe> <% form_remote_tag :update=>"message_list" :url=>"post_message" %> <%= submit_tag "Post" %> The problem is that when I submit the form it doesn''t update the message_list div. I assume that''s because it''s in a separate document. What should I put in :update so that it will update the message_list div? -- 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-/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 -~----------~----~----~----~------~----~------~--~---
Christopher Berner
2007-Oct-21 01:23 UTC
Re: How to update an iframe element with form_remote_tag?
I found a solution--maybe not the best one. For anyone that runs into the same problem what I did was I created a hidden <div> and set that as the :update parameter, then used :complete to call a javascript function that would copy the returned message into the iframe from the hidden <div>. -- 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-/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 -~----------~----~----~----~------~----~------~--~---
William Pratt
2007-Oct-21 01:40 UTC
Re: How to update an iframe element with form_remote_tag?
Why can''t you give the iframe an id and just use rjs to insert the content from the controller? Christopher Berner wrote:> I found a solution--maybe not the best one. For anyone that runs into > the same problem what I did was I created a hidden <div> and set that as > the :update parameter, then used :complete to call a javascript function > that would copy the returned message into the iframe from the hidden > <div>. >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Corey Murphy
2008-Feb-29 20:10 UTC
Re: How to update an iframe element with form_remote_tag?
William Pratt wrote:> Why can''t you give the iframe an id and just use rjs to insert the > content from the controller?This is the same dilema I have and I like what this solution poses however, I''m still not great an using javascript within rails. I''m good with javascript just not intermixing. I have a iframe that renders a partial (containing a list) using a "url_for" in the src attribute of the iframe. The list provides the user the ability to move list items up or down in the list, which I''d then like to update by re-rendering the partial. Problem is all my "link_to_remote.." links in the list don''t function now that the partial is rendered in the iframe. I''m guessing that''s because the link_to_remotes are attempting to update a div that wraps the iframe but I wouldn''t know what else to update. Why doesn''t just updating or re-rendering the partial update the partial within the iframe? -- 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-/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 -~----------~----~----~----~------~----~------~--~---
Mark Reginald James
2008-Mar-01 04:39 UTC
Re: How to update an iframe element with form_remote_tag?
Corey Murphy wrote:> I have a iframe that renders a partial (containing a list) using a > "url_for" in the src attribute of the iframe. The list provides the > user the ability to move list items up or down in the list, which I''d > then like to update by re-rendering the partial. Problem is all my > "link_to_remote.." links in the list don''t function now that the partial > is rendered in the iframe. I''m guessing that''s because the > link_to_remotes are attempting to update a div that wraps the iframe but > I wouldn''t know what else to update. Why doesn''t just updating or > re-rendering the partial update the partial within the iframe?You''ll have to create a special layout for the iframe that wraps a simple HTML head and body, with the head containing a link to prototype.js. May I ask why you''re using an iframe? Could you get away with an "overflow: auto" div? -- We develop, watch us RoR, in numbers too big to ignore. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Corey Murphy
2008-Mar-03 15:10 UTC
Re: How to update an iframe element with form_remote_tag?
Mark Reginald James wrote:> You''ll have to create a special layout for the iframe that wraps > a simple HTML head and body, with the head containing a link > to prototype.js. > > May I ask why you''re using an iframe? Could you get away with > an "overflow: auto" div? > > -- > We develop, watch us RoR, in numbers too big to ignore.I ended up using exactly that solution (div with overflow). I was only looking for the scrolling ability however, once I had encountered the iframe issue, it became my mission to resolve the problem that way or at least get a better understanding of why it behaved the way it did. Thanks for the help, -- 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-/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 -~----------~----~----~----~------~----~------~--~---