Forum: Ruby on Rails .rjs template newbie help

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
27d842adc36d4b835b164dc2606a5d17?d=identicon&s=25 Paul Smith (catalystmediastudios)
on 2007-03-25 01:47
Hi everyone I'm very new to Ruby on Rails and have just gotten a
slideshow type application working. In one div there are all the images
in the database and when you click it an AJAX call is made that makes
the image appear in another div called "divProductDisplay". I have it
all working with the AJAX and everything, but I can't figure out how to
get the visual effects working the way I want. I want the product to
appear when an image is first clicked, and when another image is clicked
I want the image to disappear and then have the image that was just
clicked reappear.Here is what I have in the .rjs template right now:

page.replace_html("divProductDisplay", :partial => "product_display")
page.visual_effect(:toggle_appear, "divProductDisplay")

This WORKS, but it will appear an image when clicked and then disappear
the image when another is clicked. I don't know how to write anything to
get this working write as I am very knew to Rails and any back-end
programming language. If you need any other information tell me what you
need. Thanks for any help you can offer.
27d842adc36d4b835b164dc2606a5d17?d=identicon&s=25 Paul Smith (catalystmediastudios)
on 2007-03-25 05:36
Do you need any more information for this.
8217faf2bfdfa7daf10135d41ddd421e?d=identicon&s=25 Jeff Cohen (jeff)
on 2007-03-25 06:10
(Received via mailing list)
On Mar 24, 7:47 pm, Paul Smith <>
> page.replace_html("divProductDisplay", :partial => "product_display")
> page.visual_effect(:toggle_appear, "divProductDisplay")

I'm not an RJS expert myself yet, but, I don't think toggle_appear is
what you want.  If I understand correctly, when an image is clicked:

1. The current image in divProductDisplay should fade away
2. The image in divProductDisplay should be replaced with the newly
selected image
3. The new image should now appear

 I think part of the problem is your code is replacing the image,
*then* toggling the appearance afterward, which isn't right.

So I think all you need to do is do another
page.visual_effect :toggle_appear, 'divProductDisplay' before you do
your replace_html.

Hope this helps,
27d842adc36d4b835b164dc2606a5d17?d=identicon&s=25 Paul Smith (catalystmediastudios)
on 2007-03-25 21:25
Hmm I tried it and it did the exact same thing anyone else with some
This topic is locked and can not be replied to.