Forum: Ruby on Rails Updating set of images with RJS

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
96956a77a329c7f8622e7c81396655fd?d=identicon&s=25 Justin Williams (Guest)
on 2007-01-19 16:31
(Received via mailing list)
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}
96956a77a329c7f8622e7c81396655fd?d=identicon&s=25 Justin Williams (Guest)
on 2007-09-25 22:46
(Received via mailing list)
anyone?    im still stumped on this one.

- j
This topic is locked and can not be replied to.