# Updating set of images with RJS

**URL:** <https://www.ruby-forum.com/t/updating-set-of-images-with-rjs/82633>\
**Category:** Rails\
**Created:** [January 19, 2007, 4:31pm UTC](https://www.ruby-forum.com/t/updating-set-of-images-with-rjs/82633 "2007-01-19T16:31:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rubylover](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8c91f0/32.png) [@rubylover](https://www.ruby-forum.com/u/rubylover)\
**Post date:** [January 19, 2007, 4:31pm UTC](https://www.ruby-forum.com/t/updating-set-of-images-with-rjs/82633/1 "2007-01-19T16:31:51Z")

</div>

I allow users to dynamically add and remove phone numbers with Ajax.  
They can then mark the primary number by clicking on a star which  
triggers an Ajax method to update the primary number.

That method calls an RJS template that I need to modify the newly  
selected star as primary by changing its image to be star.gif & making  
the other images become star\_off.gif.

I am able to get the star image updating working partially, but I am  
not sure how to pass the index parameter to my RJS call so that  
everything will stay numbered correctly in my array.

I am also not sure how to go about converting all non-primary images  
(including the previous primary) to be star\_off while leaving the new  
primary as star\_on.

Relevant code below. Help is appreciated. Thanks!

\_star.rhtml

\<%= link\_to\_remote “#{star\_image(phone, index)}”, :url =\> {:controller  
=\> ‘contacts’, :action =\>‘mark\_as\_primary\_phone’, :id =\> phone, :index  
=\> index} %\>

mark\_as\_primary.rjs

page.replace ‘phone\_off’, :partial =\> “/shared/star”, :locals =\> {  
:phone =\> @phone}

---

<div class="post-metadata">

**Author:** ![rubylover](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8c91f0/32.png) [@rubylover](https://www.ruby-forum.com/u/rubylover)\
**Post date:** [September 25, 2007, 10:46pm UTC](https://www.ruby-forum.com/t/updating-set-of-images-with-rjs/82633/2 "2007-09-25T22:46:17Z")

</div>

anyone? im still stumped on this one.

- j
