JS error when adding/removing items on a form

Hi,

I'm getting a Javascript error using tried and true RailsCast code!
I'm submitting a single form for one object (ec_order), which has many
of another object (ec_line_item) within it. I have links to add and
remove items in the form. Here is the view:

<% form_for :ec_order, :url => 'summary' do |f| %>
<table>
        <tr>
                <td>Item</td>
                <td></td>
        </tr>
        <tr><td>
                <table cellpadding="0" cellspacing="0" border="0">
                        <tr><td>
                                <div id="ec_line_items">
                                <%= render :partial =>
'ec_line_item', :collection => @ec_order.ec_line_items %>
                                </div>
                                <%= add_prescription_link "Add a
prescription" %>
                        </td></tr>
                </table>
        </td></tr>
        <tr><td align="center"><%= submit_tag("Submit Form") %></td></

</table>
<% end %>

and here is the partial

<div class="ec_line_item">
                <% fields_for "ec_order[ec_line_item_attributes][]",
ec_line_item do |ec_line_item_form| %>
     <tr><td>
       <table>
         <tr>
           <td><%= ec_line_item_form.text_field :prescription_number
%></td>
           <td><%= ec_line_item_form.text_field :description %></td>
           <td><%= link_to_function "remove",
"this.up('.ec_line_item').remove()" %></td>
         </tr>
         <tr>
           <td align="center">Prescription Number</td>
           <td align="center">Description</td>
           <td></td>
         </tr>
       </table>
     </td></tr>
                <% end %>
</div>

When I click on the "remove" link I get the JS error
"this.up(".ec_line_item") has no properties". Any ideas what I'm
doing wrong? - Dave

I suspect that the problem is that up is a method on the prototype-
extended Element 'class'. The examples in the api suggest this -- $
('some_dom_id').up() -- the dollar-sign function extends the object as
required.

Have you tried something like $(this).up(".ec_line_item").remove()

I tried this as well and got the error "$(this).up(".ec_line_item")
has no properties"

Thanks though, - Dave