Topic: Problem with RJS

Hi , I am very new when it comes to using rjs.
Here is the problem.

in my list.rhtml, I have the following code

<%ids.each do |id|%>
<%= link_to_remote "show", :update => "mydiv", :url => {:action => "show", :id => id}%>
<%= link_to_remote "cancel", :url => {:action => "cancel"}%>
<div id="mydiv#{id}"></div>
<%end%>

I have a well defined show action and its corresponding show.rhtml.
I have cancel action and corresponding cancel.rjs having the following code

page.visual_effect :fade, 'mydiv', :duration => 2

When I click on show link, the div gets updated. When I click on cancel the div fades out and its working. But when I click on show again, the div is not getting updated. Therefore I need to refresh the whole page to see the show again. Is there any thing to do with my code? Have I gone wrong any where? Any help appreciated..

thanks and regards,
venkat

Re: Problem with RJS

my guess is: the show action renders a partial back that replaces the content of mydiv. Am i right?

Well, the problem is: the fade effect of the cancel action sets a CSS style "display: none;" on the mydiv tag, and that style is not removed by the show action as it only replaces the content. so the new content IS in the div when you click show again, but the whole div is hidden.

my suggestion: use RJs in the show action too:
1)remove the :update => "mydiv" option from the link_to_remote
2) RJS:

page.replace_html "mydiv", :partial => 'show'
page['mydiv'].show
#make the div visible by removing the display:none; style with this command.
# You could also use an effect here if you wanted to.

Re: Problem with RJS

Hi Thanks for the help. It works great...