# Newbie question - rjs updating a table cell

**URL:** <https://www.ruby-forum.com/t/newbie-question-rjs-updating-a-table-cell/134124>\
**Category:** Rails\
**Created:** [April 8, 2008, 3:45am UTC](https://www.ruby-forum.com/t/newbie-question-rjs-updating-a-table-cell/134124 "2008-04-08T03:45:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tubahead](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/8e7dd6/32.png) [@Tubahead](https://www.ruby-forum.com/u/Tubahead)\
**Post date:** [April 8, 2008, 3:45am UTC](https://www.ruby-forum.com/t/newbie-question-rjs-updating-a-table-cell/134124/1 "2008-04-08T03:45:50Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Tubahead](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/8e7dd6/32.png) [@Tubahead](https://www.ruby-forum.com/u/Tubahead)\
**Post date:** [April 8, 2008, 3:49am UTC](https://www.ruby-forum.com/t/newbie-question-rjs-updating-a-table-cell/134124/2 "2008-04-08T03:49:20Z")

</div>

Hi.

the row you want has to have an id:

 blah another blah

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/](http://sensei.zenunit.com/)

---

<div class="post-metadata">

**Author:** ![Tubahead](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/8e7dd6/32.png) [@Tubahead](https://www.ruby-forum.com/u/Tubahead)\
**Post date:** [April 8, 2008, 3:55am UTC](https://www.ruby-forum.com/t/newbie-question-rjs-updating-a-table-cell/134124/3 "2008-04-08T03:55:11Z")

</div>

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.

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

```

id=“edit\_csession\_3” method=“post”  
…

---

<div class="post-metadata">

**Author:** ![Tubahead](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/8e7dd6/32.png) [@Tubahead](https://www.ruby-forum.com/u/Tubahead)\
**Post date:** [April 8, 2008, 3:59am UTC](https://www.ruby-forum.com/t/newbie-question-rjs-updating-a-table-cell/134124/4 "2008-04-08T03:59:16Z")

</div>

Very cool !!

This is what I used:  
page.hide(“customer\_#{@cust.id}”)

Thank you very much …

---

<div class="post-metadata">

**Author:** ![Tubahead](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/8e7dd6/32.png) [@Tubahead](https://www.ruby-forum.com/u/Tubahead)\
**Post date:** [April 9, 2008, 3:48pm UTC](https://www.ruby-forum.com/t/newbie-question-rjs-updating-a-table-cell/134124/5 "2008-04-09T15:48:49Z")

</div>

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

page.hide dom\_id(@cust)
