The before hook would be nice to prevent the addition of a new fieldset in
case the developer wants to limit the number of children a user can submit.
 But I think its more important to get access to the newly inserted fieldset


On Sun, Nov 3, 2013 at 1:52 PM, Sean Linsley <notifications@github.com>wrote:

> In app/assets/javascripts/active_admin/components/has_many.js.coffee:
>
> > +  String(html).replace(/&amp;/g, '&').replace(/&lt;/g, '<').replace(/&gt;/g,'>').
> replace(/&quot;/g, '"').replace(/&#x27;/g, "'")
> > +
> > +$ ->
> > +  $(document).on 'click', 'a.button.has_many_remove', (e)->
> > +    e.preventDefault()
> > +    $(@).closest('.has_many_fields').remove()
> > +
> > +  $('a.button.has_many_add').click (e)->
> > +    e.preventDefault()
> > +    $(@).trigger 'has_many_add:before'
> > +
> > +    @has_many_index ||= $(@).siblings('fieldset').length
> > +    regex             = new RegExp $(@).data('placeholder'), 'g'
> > +    $(@).before unescape_html $(@).data('html').replace regex, ++@has_many_index
> > +
> > +    $(@).trigger 'has_many_add:after'
>
> The problem is that then the before and after hooks would have a different
> interface. Which brings up the question: is there really a need to have a
> before hook? I added it in because it seemed like a nice thing to have, but
> I can't seem to think of a situation where it would actually be useful.
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/gregbell/active_admin/pull/2645/files#r7391553>
> .
>