Currently, I allow my users to dynamically add new fields to a form using the link_to_function variable. However, whenever a new field is added, its inputs have the same names as the previous fields. I solved this by passing in a local variable, but I can't get that value to increment (or update) on click.
I'm using the following code: <%= link_to_function "Add Another" do |page| page.insert_html :bottom, :tasks, :partial => 'stuff', :object => Model.new, :locals => { :num => 1 } end%> (Yes, that code was take from ryan bates's complex forms series.) How do I get that :num => 1 to increment every time a user clicks "Add Another." increment and increment! don't seem to work, and I thought about using Time.now.to_i instead of single digit integers (note: it doesn't matter what "num" is as long as it's a number), but that only loads the time when page is first loaded, and doesn't update when "Add Another" is clicked. So, is there anyway to increment this :num value using client side javascript? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.