sehmaschine/django-grappelli — Issue #51: Trigger events when inlines are added/removed
Author: kylefox
Created: 2011-10-23 22:26:34+00:00
State: open

I have some JavaScript I need to run when a user clicks the "Add another
" link in an inline form. My JavaScript needs to execute _after_ the new inline form has been appended to the document, so a simple click() handler on the link won't work.

There doesn't appear to be an easy way to do this. For now I've resorted to using a gross hack with setInterval, where I monitor the page for changes.

It would be *awesome* if Grappelli fired events when inline forms are added or removed, for example:

$(document).bind('grappelli:inline:added', function(form) {
// Do something with the newly added inline form.
});

This is a far less obtrusive style than passing callbacks into the `$.grp_inline` function.

If you agree with the style I propose, I'd be happy to submit patches.