NEWBIE: replace_html not working as I expected HELP!!!

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 %>

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

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!!