how to update a single table cell using ajax

32 views
Skip to first unread message

Tomasz Romanowski

unread,
Jul 28, 2010, 11:30:25 AM7/28/10
to rubyonra...@googlegroups.com
I'm trying to update a table cell based upon a selection in another cell
identified as "descPlaceholder". However, instead of getting the
intended cell updated the updated string gets displayed completely
outside of the table in a seemingly arbitrary spot on the form.

The form:

<table>
<tr>
<th>Code</th>
<th>Name</th>
<th>Quantity</th>
</tr>
<tr>
<td>
<%= select_tag :partcode,
options_from_collection_for_select(@parts, 'id', 'code')
%>
<%= observe_field(:partcode,
:update => :descPlaceholder,
:url => {:action => :getPartName})
%>
</td>
<div id="descPlaceholder">
<td>placeholder for description</td>
</div>
<td>
<%= text_field "partquantity", "quantity", :size =>5, :maxlength
=>5 %>
</td>
</tr>
</table>


getPartName.html.erb:
<td>Test Description</td>


getPartName method:
def
end
--
Posted via http://www.ruby-forum.com/.

Hassan Schroeder

unread,
Jul 28, 2010, 12:04:00 PM7/28/10
to rubyonra...@googlegroups.com
On Wed, Jul 28, 2010 at 8:30 AM, Tomasz Romanowski <li...@ruby-forum.com> wrote:
> I'm trying to update a table cell based upon a selection in another cell
> identified as "descPlaceholder". However, instead of getting the
> intended cell updated the updated string gets displayed completely
> outside of the table in a seemingly arbitrary spot on the form.

>      </td>


>      <div id="descPlaceholder">
>        <td>placeholder for description</td>
>      </div>
>      <td>

That'll never work because it's not valid HTML; a DIV can't be a child
of a TR.

--
Hassan Schroeder ------------------------ hassan.s...@gmail.com
twitter: @hassan

Eric Yen

unread,
Jul 29, 2010, 8:59:12 AM7/29/10
to Ruby on Rails: Talk
You can alwaus just do the following:

<td id="descPlaceholder">

Tomasz Romanowski

unread,
Jul 30, 2010, 9:52:40 AM7/30/10
to rubyonra...@googlegroups.com
Eric Yen wrote:
> You can alwaus just do the following:
>
> <td id="descPlaceholder">


Wow, many thanks to both of you!

Reply all
Reply to author
Forward
0 new messages