Re: Problems with link_to_remote

user splash
2008-01-24T05:50:15Z

> What I am trying to do is to create an link that adds a new label and
> text field when i click it.
>
>
> Example:
>
> <% form_for :item, :url => { :action => :save_item}, :html => {
:id =>
> "item" } do |n| %>
>
>
>
> Item
0
> <%= n.text_field :item
%> <%=
> link_to_remote( "add", :update => "content", :url
=>{ :action =>
> :add_item }, :position => "bottom") %>
>
>
>
>
>
> <%= link_to_function ''Previous'',
"$(''item'').submit()" -%>
>
>
>
>
>
> <% end %>
>
>
>
>
> After I click the link, "add", I will get the following result:
>
> Item 0         text field
> Item 1         text field           add(this is a link)
>    .
>    .
>    .
>
> When the link is being clicked, another label and text field will be
> added to the table, the number beside "Item" will increment and
the


Sorry I misssed out my controller.

In my controller:

def add_item
render(:inline => %{
TEXT FOR BIN CODE
1
<%= n.text_field :item %>
})
  end



When I click the link, I got this error, undefined local variable or
method `n'' for #<#<Class:0x482c428>:0x482c400>. When I take
away the n,
I got this error, wrong number of arguments (1 for 2). Where did I go
wrong and adding on to the previous questions, how can I display the
things that will show after I click the link in the correct place, which
is under the td tag of the orginal?