﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
31170	dismissRelatedLookupPopup doesn't trigger change event	J. David Ibáñez	Kairat Makym	"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();
     }
}}}"	Bug	closed	contrib.admin	3.0	Normal	fixed			Ready for checkin	1	0	0	0	1	0
