Re: [Django] #35277: Issue with the new "formset:added" event

2024-03-06 Thread Django
#35277: Issue with the new "formset:added" event
-+-
 Reporter:  meesterguyman|Owner:  nobody
 Type:   |   Status:  closed
  Cleanup/optimization   |
Component:  contrib.admin|  Version:  5.0
 Severity:  Normal   |   Resolution:  invalid
 Keywords:   | Triage Stage:
 |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Mariusz Felisiak):

 * cc: Claude Paroz (added)
 * resolution:   => invalid
 * status:  new => closed

Comment:

 This is an intended change (eabc22f919e6c1774842e628400b87ac56c47bce) that
 it [https://docs.djangoproject.com/en/stable/ref/contrib/admin/javascript
 /#inline-form-events documented] and mentioned in
 [https://docs.djangoproject.com/en/stable/releases/4.1/#miscellaneous
 release notes], so revert is not an option. Also, it's explicitly
 documented that:
 > ''"For the `formset:added` event, `event.target` **is the newly added
 row.**"''
-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018e173f70a7-5504b755-a7d0-45b0-90e8-5ffb9cd9cc23-00%40eu-central-1.amazonses.com.


[Django] #35277: Issue with the new "formset:added" event

2024-03-06 Thread Django
#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: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018e15f52f1a-908fa1d2-3e0b-4f06-823a-44e716073ac9-00%40eu-central-1.amazonses.com.