Hi:
I have a small piece of code I’m injecting into a page using a partial
and RJS. Trick is, the code I’m injecting is a form field, and the id
needs to have a digit at the end of it so I can grab it when I submit
the form. I can’t seem to get the partial to render with the variable
incremented.
My RJS:
page.insert_html :bottom, ‘new_task’, :partial => ‘add_new’
page.visual_effect :highlight, ‘new_task’
My partial:
NOTE: here’s where it gets interesting - see the first line? I’m trying
here to increment the instance variable @task. Note that this @task is
set to 3 when the page itself (page = multiple) loads.
<% @task = @task.succ %>
Controller method for the page (simple):
def multiple
@task = 3
end
Controller method for the partial taks (“add_new”)
NOTE: I’ve currently tried it as empty. When I have it as empty the
variable never increments in the partial. When I have only one line in
this method (@task = @task.succ), I get an error: “NoMethodError in
Goals#add_new”; When just set the instance variable (@task = 4), it
comes through no problem, but it still doesn’t increment when the
partial is rendered.
def add_new
end
The key here is that this partial should be able to be injected into the
form infintely, which is essentially what I want, but I can’t get it to
increment correctly.
Thanks in advance for any help you can provide.
Mike