Re: JS error when adding/removing items on a form

laredotornado-8iDLEspWrrZBDgjK7y7TUQ@public.gmane.org
Fri, 01 Feb 2008 19:44:00 -0000

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

Thanks though, - Dave

On Feb 1, 10:35 am, AndyV <a...-HmMyXyqgL2CVc3sceRu5cw@public.gmane.org>
wrote:
> 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()
>
> On Feb 1, 11:10 am,
"laredotorn...-8iDLEspWrrZBDgjK7y7TUQ@public.gmane.org"
>
>
>
> <laredotorn...-8iDLEspWrrZBDgjK7y7TUQ@public.gmane.org> wrote:
> > 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">
> >
> >                                 <div
id="ec_line_items">
> >                                 <%= 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- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
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@googlegroups.com