I was hoping the following code would generate a new turing everytime it was click. But it renders everything the first time the page is rendered and replaces the image once.. but also has already set to session[turing] to the last call to createturing.. so the first image and session[turing] don;t match!!! I thought moving to a partial would hold off the execution of the partial until the link was clicked... guess not!!! how should i implement this? <div id="turing"><%= render(:partial => "createturing" ) %></div> <%= link_to_function ''refresh'' do |page| page.replace_html ''turing'', render(:partial => ''createturing'') end %> --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2007-Dec-27 02:19 UTC
Re: NEWBIE: replace_html not working as I expected HELP!!!
On 27 Dec 2007, at 02:03, spokra wrote:> > I was hoping the following code would generate a new turing everytime > it was click. But it renders everything the first time the page is > rendered and replaces the image once.. but also has already set to > session[turing] to the last call to createturing.. so the first image > and session[turing] don;t match!!! I thought moving to a partial > would hold off the execution of the partial until the link was > clicked... guess not!!! >No as you found out, this is all evaluated in one go (How could it be otherwise since rendering the partial can only happen serverside?)> how should i implement this? > > <div id="turing"><%= render(:partial => "createturing" ) %></div> > <%= link_to_function ''refresh'' do |page| > page.replace_html ''turing'', render(:partial => ''createturing'') > end %> >You can use link_to_remote to make an ajax call. 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 -~----------~----~----~----~------~----~------~--~---
Steep learing curve but I''m starting to get it!!! Thanks that did the quick and after getting your pointer it only took me a few minutes to implement it!! thats rapid!! On Dec 26, 6:19 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 27 Dec 2007, at 02:03, spokra wrote: > > > > > I was hoping the following code would generate a new turing everytime > > it was click. But it renders everything the first time the page is > > rendered and replaces the image once.. but also has already set to > > session[turing] to the last call to createturing.. so the first image > > and session[turing] don;t match!!! I thought moving to a partial > > would hold off the execution of the partial until the link was > > clicked... guess not!!! > > No as you found out, this is all evaluated in one go (How could it be > otherwise since rendering the partial can only happen serverside?)> how should i implement this? > > > <div id="turing"><%= render(:partial => "createturing" ) %></div> > > <%= link_to_function ''refresh'' do |page| > > page.replace_html ''turing'', render(:partial => ''createturing'') > > end %> > > You can use link_to_remote to make an ajax call. > > 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---