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?

<%= render(:partial => "createturing" ) %>
<%= link_to_function 'refresh' do |page| page.replace_html 'turing', render(:partial => 'createturing') end %>

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?

<%= render(:partial => "createturing" ) %>
<%= 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!!

On Dec 26, 6:19 pm, Frederick C. [email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs