When I click the link, a new label with the number incremented, Item 1
and a new text field will appear below the previous label, Item 0 and
text field. Can anyone tell me how can I acheive that?
oh…After changing the class to id it I manage to display some text. As
I use this codes in the controller to test out the link.
def add_item
render_text “
Item ” + DateTime.now.to_s + “
”
end
But there are still some problems and questions I want to ask. Even
though in the link_to_remote, I set the text to be displayed after the
original label and text field by using :position => “bottom”, the text
is being displayed on top of the original one. Can someone tell me why
or what happened here?
The other question is when I click the link, a new label with the number
incremented, Item 1 and a new text field will appear below the previous
label, Item 0 and text field. How do I achieve that?
I missed out a question. As Ryan B. said, I can’t put a div inside a
table row. How can I display the things i want to display below that
row, the row with the original label and text field?
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?
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?
Hi,
Can anyone please help me with the above two posting’s questions?
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
link, “add” will be next to the new added row.
I am not sure how can I achieve that. I hope the above explaination is
clear enough. Can someone please help me ?
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
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
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
Hi,
Thanks. It works. But there is a problem. I have no idea how to loop
this. Can anyone give me some clue?
I loop to get the incementing number for Item some_number. I tried many
way to get this counter thing right. Please direct me to the right path
if I am wrong.
How do I or should I do this counter?