# .rjs template newbie help

**URL:** <https://www.ruby-forum.com/t/rjs-template-newbie-help/90017>\
**Category:** Rails\
**Created:** [March 25, 2007, 1:47am UTC](https://www.ruby-forum.com/t/rjs-template-newbie-help/90017 "2007-03-25T01:47:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![azgar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/eb8c5e/32.png) [@azgar](https://www.ruby-forum.com/u/azgar)\
**Post date:** [March 25, 2007, 1:47am UTC](https://www.ruby-forum.com/t/rjs-template-newbie-help/90017/1 "2007-03-25T01:47:52Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![azgar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/eb8c5e/32.png) [@azgar](https://www.ruby-forum.com/u/azgar)\
**Post date:** [March 25, 2007, 5:36am UTC](https://www.ruby-forum.com/t/rjs-template-newbie-help/90017/2 "2007-03-25T05:36:55Z")

</div>

Do you need any more information for this.

---

<div class="post-metadata">

**Author:** ![azgar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/eb8c5e/32.png) [@azgar](https://www.ruby-forum.com/u/azgar)\
**Post date:** [March 25, 2007, 6:10am UTC](https://www.ruby-forum.com/t/rjs-template-newbie-help/90017/3 "2007-03-25T06:10:23Z")

</div>

On Mar 24, 7:47 pm, Paul S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> 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,  
Jeff

> **[Hey Daddio!](http://softiesonrails.com)**
>
> Home of Hey Daddio Software

---

<div class="post-metadata">

**Author:** ![azgar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/eb8c5e/32.png) [@azgar](https://www.ruby-forum.com/u/azgar)\
**Post date:** [March 25, 2007, 9:25pm UTC](https://www.ruby-forum.com/t/rjs-template-newbie-help/90017/4 "2007-03-25T21:25:47Z")

</div>

Hmm I tried it and it did the exact same thing anyone else with some  
suggestions?
