Newbie question - rjs updating a table cell


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,



the row you want has to have an id:

blah another blah

then in the rjs you can:


and that will work fine.


Learn Ruby on Rails! Check out the FREE VIDS (for a limited time)
VIDEO #3 out NOW!

I have an ID to refer to, but I don’t know how to issue a variable
quite right.
I imaged something like:
:customer#{} - 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.

<td>firstname, lastname</td>
<form action="/csessions/3" class="edit_csession"

id=“edit_csession_3” method=“post”

Very cool !!

This is what I used:

Thank you very much …

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

page.hide dom_id(@cust)

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs