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?
I missed out a question. As Ryan Bigg 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
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 ?
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 => %{<tr>
<td style="width: 374px;"><label>TEXT FOR BIN CODE 1</label></td>
<td style="width: 219px;"><%= n.text_field :item %>
</tr>})
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?
def add_item
render(:inline => %{<tr>
<td style="width: 374px;"><label>TEXT FOR BIN CODE 1</label></td>
<td style="width: 219px;"><%= n.text_field :item %>
</tr>})
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?
Hi,
Can anyone please help me with the above two posting's questions?
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.
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?
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?
Why involve the session? If you want to do something 5 times then it's
as simple as
Why involve the session? If you want to do something 5 times then it's
as simple as
<% 5.times.do |index| %>
...
<% end %>
Fred
But won't that print the stuff inside the <% 5.times do |index| %> 5
times when the link is clicked? I only want the stuff to be printed out
once with the number incremented each time the link is clicked.
Example:
Item 0 when link is clicked,
Item 1 when link is clicked,
Item 2 and so on.