Is there any way to pass a unique identifier to each iteration of a
partial generated using the :collection option?
I have a form that contains a variable number of text fields that
collect data into an array that’s processed in the controller upon
submit. A text field can be added to the form using an AJAX request
that adds a new blank object to a collection and re-renders the partial
using the new collection. The thing is, I need to be able to remove
text fields also, so they need to have a unique ID.
Is there some sort of unique identifier that is passed into the partial
when you’re using the :collection option?
Is there any way to pass a unique identifier to each iteration of a
partial generated using the :collection option?
I have a form that contains a variable number of text fields that
collect data into an array that’s processed in the controller upon
submit. A text field can be added to the form using an AJAX request
that adds a new blank object to a collection and re-renders the partial
using the new collection. The thing is, I need to be able to remove
text fields also, so they need to have a unique ID.
Is there some sort of unique identifier that is passed into the partial
when you’re using the :collection option?
Andrew
Nevermind! I just found the “free” _counter variable that is made
available to each iteration of the partial.