Forum: Ruby on Rails Possible RJS Implementation?

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.
12be02204a4bcaeec2c6c369fe53a45b?d=identicon&s=25 Dave Hoefler (Guest)
on 2006-06-01 23:38
(Received via mailing list)
Hi there,

I have a question regarding updating elements of a two different divs
one click. I have two lists. One list holds items that are entered into
contest, and the other list holds items that aren't currently in the
contest. One item can only be in one list at a time.

Each list has a partial that renders the items with corresponding
The items in the current contest list have an action of 'remove from
contest' and the items currently not in a contest have an action of 'add

When one item is added or removed from their appropriate list I would
for it to fade in on the other list.

I currently have the fade out part working fine on both lists when an
is selected. It's the dynamically adding a new div id on the other list
that's giving me some issues.

Here's what I currently have for the remove and add to list:

The items that are available:

<div id="elgibile_songs_holder">
    <% for song in @elgibile_songs %>
        <div class="elgibile_song" id="elgibile_id_of_<%= %>">
            <div class="elgibile_title"><%= song.title %></div>

            <div class="elgibile_entered_link">

                <%= link_to_remote h("Submit to this contest"), {
                             :url => { :action => 'contest_enter', :id
@contest, :song_id => },
                            :complete => visual_effect(:fade,
"elgibile_id_of_#{}")} %>

    <% end %>

The items that are no available:
<div id="ineligible_songs_holder">
    <% for song in @ineligible_songs %>
        <div class="ineligible_song" id="id_of_<%= %>">
            <div class="ineligible_title"><%= song.title %></div>

            <div class="ineligible_entered_link">

                <%= link_to_remote h("Remove from this contest"), {
                             :url => { :action => 'contest_unsubmit',
:id =>
@contest, :song_id => },
                            :complete => visual_effect(:fade, "id_of_#{}", :duration => 1),
                            :confirm => "Are you sure you want to remove
\"#{song.title}\" from the contest?" }%>

    <% end %>

The two actions in the methods that handle the corresponding actions
like this:

def contest_enter
   #enter2: finish submission of song to contest
   @contest = Contest.find(params[:id])
   @song = Song.find(params[:song_id])
   @member = session[:member_id]
   @elgibile_songs = ContestEntry.elgibile_songs(,

 def contest_unsubmit
   #unsubmit: remove a contest entry
   @contest = Contest.find(params[:id])
   @song = Song.find(params[:song_id])
   c = ContestEntry.find_by_song_id_and_contest_id(,

Are there any tutorials that cover what I want to do? I'm thinking I may
have to explore RJS a little bit.

Thank you,
Dave Hoefler
This topic is locked and can not be replied to.