#31170: dismissRelatedLookupPopup doesn't trigger change event
-----------------------------------------+------------------------
Reporter: jdavid | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 3.0
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
-----------------------------------------+------------------------
I've a custom form with a field using ForeignKeyRawIdWidget (field1), and
a select box (field2) dependent on field1.
I've some JS listening for change events in field1, when this happens
field2 is updated.
The problem is, when field1 is chosen using the popup the change event is
not triggered, so field2 is not updated.
This is easy to fix:
{{{
--- a/django/contrib/admin/static/admin/js/admin/RelatedObjectLookups.js
+++ b/django/contrib/admin/static/admin/js/admin/RelatedObjectLookups.js
@@ -49,6 +49,9 @@
} else {
document.getElementById(name).value = chosenId;
}
+ var evt = document.createEvent("HTMLEvents");
+ evt.initEvent("change", false, true);
+ elem.dispatchEvent(evt);
win.close();
}
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/31170>
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/049.f0a451ba8df4e03001f5e6fd5419b2d1%40djangoproject.com.