I want to have a form that adds new groups of the same input fields via
link_to_remote. I then want to collect those groups and insert them all
into the database.
So if I have a database that’s for groups of flashcards, with the card
id as the primary key, then I want to gather up the groups and insert
them at one time, looking something like this.
#this will update the “deck div”
<div class="deck">
#adds a card partial from an rjs template
<div class="card">
question: <input name="Deck[question]" />
answer: <input name="Deck[answer]" />
</div>
#adds another card etc…
<div class="card">
question: <input name="Deck[question]" />
answer: <input name="Deck[answer]" />
</div>
</div>
I don’t have any problems adding the input fields, but I’m looking for a
way to identify the “card divs” with unique id’s, for if I wanted to
remove the elements, and I’m also trying to figure out how to get these
redundant fields in the database through one form. I’m looking around
to see if I can increment and assign a number id to the card div each
time a card is added, but no luck so far.
any help would be great!