Re: Problems with link_to_remote

Keynan Pratt
2008-01-24T07:41:45Z

Why is it no one asking questions on here ever seems to bother reading a
programming book.

The var ''n'' does not exist. HTTP is stateless. It has no
f*cking idea
you rendered the form with "form_for do |n|" all it knows is what
comes
in the params object and no you can''t pass ''n'' in the
request.

this:
===========================================================def add_item
render(:inline => %{
TEXT FOR BIN CODE
1
<%= n.text_field :item %>
})
end
===========================================================should be in a
partial. MVC is a fundamental part of RAILS. That means
no html in your controllers. Period.

As to your layout. lose the table it will only make this harder. Tables
are for tabular data ONLY.

You end up with:

==================================================def add_item
  render(:partial => ''item_inputs'')
end
==================================================
#item_inputs

Item <%= some_counter %>
<%= text_field :item, :item %>

==================================================
# the form



  <% form_for :item, :url => { :action => :save_item}, :html => {
:id =>
"item" } do |n| %>
Item 0
    <%= n.text_field :item %>
    <%= link_to_remote( "add", :update => "button",
:url =>{ :action =>
:add_item }, :position => "above") %>

<%= link_to_function ''Previous'',
"$(''item'').submit()" -%>

  <% end %>


===================================================
use anything but a table to wrap that markup and you should be fine.
Though it would be better to strip down that link_to_remote and push the
extra stuff into the partial to work a rjs