I am combining div toggling with complex forms: http://railscasts.com/episodes/75-complex-forms-part-3
My specific situation: I have a few nested fields being built in table/new.html.erb
and Customer/_customer_note_fields
. Ordinarily, I would do something like the following to have toggled divs:
# view
<a class="toggle" rel="toggle[expand#<%= note.id %>]">"Click me"</a>
<div class="expand_me" id="<%= "expand#{note.id}" -%>">
"Hello!"
</div>
The problem with the current case is that it is in the middle of a form builder where all the records are new - therefore, they have no IDs! Therefore, there is no unique marker for these divs.
Is there some other unique number belonging to a new unsaved record that I can access? How would you deal with this problem?