#35277: Issue with the new "formset:added" event
------------------------------------------------+------------------------
Reporter: meesterguyman | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: contrib.admin | Version: 5.0
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------------------+------------------------
We have certain custom widgets that need to be initialized when a new form
is added to an inline. Previously, this event was triggered by the
following:
{{{
$(document).trigger("formset:added", [row, options.prefix]);
}}}
We could then use jQuery's "on" method to add whatever callbacks needed to
be executed. Most importantly, the "row" that was added could be was
passed to the callback, making it very easy to do what we needed to that
particular row. In 5.0, this was eliminated, and we have the following
code instead:
{{{
row.get(0).dispatchEvent(new CustomEvent("formset:added", {
bubbles: true,
detail: {
formsetName: options.prefix
}
}));
}}}
Not sure what the rational for this change was, but would really
appreciate if you all could at least include the "row" in the detail
passed here, or preferably revert to the previous code.
Source is below:
https://github.com/django/django/blob/c4df2a77761a1ae392eb5c4803b5712803d5239f/django/contrib/admin/static/admin/js/inlines.js#L91C24-L91C37
--
Ticket URL: <https://code.djangoproject.com/ticket/35277>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/0107018e15f52f1a-908fa1d2-3e0b-4f06-823a-44e716073ac9-000000%40eu-central-1.amazonses.com.