2

I am using Ryan Bates' Nested Form in Rails 3.2.13 and am having an issue getting the correct indexes when trying to embed some javascript.

I am able to get the index for dynamically generated content using:

=f.fields_for :entity, :wrapper => false do |e|
  =e.input :name
  %div{ :id => "entity_#{e.options[:child_index]}" }
  :javascript
    $("entity_#{e.options[:child_index]}").foo()

However, when editting this same form with existing data the index is blank for the rows that have data.

It looks like e.options[:nested_child_index] should contain the correct value but I get a private variable exception when attempting to access it.

How should I get the correct index so I can pass it along?

4

0 回答 0