nathanvda / cocoon

Dynamic nested forms using jQuery made easy; works with formtastic, simple_form or default forms
http://github.com/nathanvda/cocoon
MIT License
3.08k stars 385 forks source link

Fill data after insert #543

Closed cokeito closed 5 years ago

cokeito commented 5 years ago

Hello guys! i have an object that have the data that i need to fill on the "new added items" im triggering via jquery the click method to generate a new field with 4 fields, i have the data for the 4 fields already in an object, so how i can fill the data after insert if i dont have an id to fill where i can set the value of the fields.

The help is appreciated!

nathanvda commented 5 years ago

You should use the callbacks documented here: https://github.com/nathanvda/cocoon#callbacks-upon-insert-and-remove-of-items

As a parameter you receive the part of html (the partial) that is about to be or was inserted, for you to manipulate, aka fill in the fields as you wish.

If you need code to explain this, please show us some example code so I can show you.

nathanvda commented 5 years ago

Closed due to inactivity.