﻿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
26357	'related-lookup' and 'add-another' popups don't work for admin fields added via ajax	Julian Andrews	nobody	"If a field with a `'related-lookup'` or `'add-another'` link is added after page load (for instance via ajax), the javascript event handler which causes these links to open a pop-up doesn't get attached to the  new links. Instead of opening a pop-up window to allow selection of the related object, the links simply send the user to the list page for the object.

As a result ajax generated admin fields don't work correctly. While this doesn't break the Django admin itself, it does make extending the admin with Ajax difficult.

An easy fix is to attach the `'related-lookup'` and `'add-another'` `click` events to `document` instead of to the links themselves. This would come at a small performance cost since the events will be triggered on every click instead of just on link click, but with modern javascript engines I think the cost would be unnoticeable, and given how unobtrusive this change is I think the added flexibility justifies the cost.

I'll attach a PR for the proposed fix after I submit this report."	Cleanup/optimization	closed	contrib.admin	dev	Normal	fixed	admin javascript ajax		Accepted	1	0	0	0	0	1
