From 6d39cb4119a0fa502fca1f9b3d07436fbd258655 Mon Sep 17 00:00:00 2001 From: Luke Plant Date: Tue, 1 Nov 2011 21:50:17 +0000 Subject: [PATCH] Fixed #5704 - Admin popup windows won't close when using application/xhtml as default content type Thanks to Rob van der Linde for the report, and to mb0, dArignac and claudep for the patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@17065 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/contrib/admin/options.py | 4 +++- .../admin/static/admin/js/admin/RelatedObjectLookups.js | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py index 91b81a42e0a..3a0ad7475dc 100644 --- a/django/contrib/admin/options.py +++ b/django/contrib/admin/options.py @@ -779,7 +779,9 @@ class ModelAdmin(BaseModelAdmin): return HttpResponseRedirect(post_url_continue % pk_value) if "_popup" in request.POST: - return HttpResponse('' % \ + return HttpResponse( + '' + '' % \ # escape() calls force_unicode. (escape(pk_value), escapejs(obj))) elif "_addanother" in request.POST: diff --git a/django/contrib/admin/static/admin/js/admin/RelatedObjectLookups.js b/django/contrib/admin/static/admin/js/admin/RelatedObjectLookups.js index 1bc78f89b13..ce54fa50834 100644 --- a/django/contrib/admin/static/admin/js/admin/RelatedObjectLookups.js +++ b/django/contrib/admin/static/admin/js/admin/RelatedObjectLookups.js @@ -74,11 +74,12 @@ function dismissAddAnotherPopup(win, newId, newRepr) { var name = windowname_to_id(win.name); var elem = document.getElementById(name); if (elem) { - if (elem.nodeName == 'SELECT') { + var elemName = elem.nodeName.toUpperCase(); + if (elemName == 'SELECT') { var o = new Option(newRepr, newId); elem.options[elem.options.length] = o; o.selected = true; - } else if (elem.nodeName == 'INPUT') { + } else if (elemName == 'INPUT') { if (elem.className.indexOf('vManyToManyRawIdAdminField') != -1 && elem.value) { elem.value += ',' + newId; } else {