ryanb / nested_form

Rails plugin to conveniently handle multiple models in a single form.
MIT License
1.79k stars 505 forks source link

Add the generated ID as a data attribute to the new field #339

Closed ayaman closed 8 years ago

ayaman commented 9 years ago

I'm using EJS to add new nested fields to the page after making an AJAX request to the server. The issue is that with multi-level nesting, this can get quite messy since there's no easy way to find the parent ID except with a regexp.

A simple solution would be to add a data attribute to each newly added field that contains the randomly generated ID assigned to the field, which can then be used by any JS functions that need it.