newbie question - rjs updating a table cell

Hello,

I have been having trouble even learning what to search for on this issue, so please bear with me.

My page with an issue has two relevant divs: * one div contains a list of enrolled users in a class * the other div contains a search box where you can search for members to add to the class, then click to add them

I can add and remove members just fine using form_remote_for, and my rjs template works in general.

My issue: When a user clicks the button to enroll a user, I want to empty/hide the table row containing the record to show that their click worked. I could just rebuild the entire table each time they click, but this will cause the user interface issues - and it seems wasteful. I can do this by hand coding an ID, but I don't understand enough ruby to create the right kind of variable.

My RJS page:

# This line recreates the div with the current list of enrolled users page.replace_html :enrolledusers, :partial => "enrolledusers", :object => @csession

## This line is my test line, and given a table cell with an id="customer_1202" it does the correct thing.

page.replace_html :customer_1202, ""

Normally I wouldn't waste a post on this kind of question as it seems like something I should have figured out, but all my research leads me to believe everyone else already knows how to do it.

Many thanks,

Dustin

Hi.

the row you want has to have an id:

<tr id="something">   <td>blah</td>   <td>another blah</td> </tr>

then in the rjs you can:

page.hide("something')

and that will work fine.

Julian.

Learn Ruby on Rails! Check out the FREE VIDS (for a limited time)
VIDEO #3 out NOW! http://sensei.zenunit.com/

I have an ID to refer to, but I don't know how to issue a variable quite right. I imaged something like: :customer#{customer.id} - but I know this isn't right.

Oh ... never mind. page.hide("") take a text value from your example.

Let me go try this out, I appreciate your help.

<tr id="customer_990">

    <td>firstname, lastname</td>     <td>     <form action="/csessions/3" class="edit_csession" id="edit_csession_3" method="post"     .......     </form>     </td>   </tr>

Very cool !!

This is what I used: page.hide("customer_#{@cust.id}")

Thank you very much ...

If you're in Rails 2.x you can:

page.hide dom_id(@cust)