JS error when adding/removing items on a form

laredotornado-8iDLEspWrrZBDgjK7y7TUQ@public.gmane.org
Fri, 01 Feb 2008 16:10:09 -0000

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| %>


Item



                <table cellpadding="0" cellspacing="0"
border="0">


                                <%= render :partial =>
''ec_line_item'', :collection => @ec_order.ec_line_items
%>

                                <%= add_prescription_link "Add a
prescription" %>



<%=
submit_tag("Submit Form") %> </
tr>

<% end %>


and here is the partial



                <% fields_for
"ec_order[ec_line_item_attributes][]",
ec_line_item do |ec_line_item_form| %>



<%= ec_line_item_form.text_field :prescription_number
%>
<%= ec_line_item_form.text_field :description
%>
<%= link_to_function "remove",
"this.up(''.ec_line_item'').remove()" %>


Prescription Number
Description




                <% end %>



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



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org