#26357: 'related-lookup' and 'add-another' popups don't work for admin fields
added
via ajax
-------------------------------+-----------------------------------
Reporter: julianandrews | Owner: nobody
Type: Uncategorized | Status: new
Component: contrib.admin | Version: master
Severity: Normal | Keywords: admin javascript ajax
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------+-----------------------------------
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.
--
Ticket URL: <https://code.djangoproject.com/ticket/26357>
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/056.1b0260dbb309ff3f2a272d9e1a4ce4d3%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.