Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
  • Loading branch information...
commit 6d39cb4119a0fa502fca1f9b3d07436fbd258655 1 parent a97ecfd
Luke Plant authored November 01, 2011
4  django/contrib/admin/options.py
@@ -779,7 +779,9 @@ def response_add(self, request, obj, post_url_continue='../%s/'):
779 779
             return HttpResponseRedirect(post_url_continue % pk_value)
780 780
 
781 781
         if "_popup" in request.POST:
782  
-            return HttpResponse('<script type="text/javascript">opener.dismissAddAnotherPopup(window, "%s", "%s");</script>' % \
  782
+            return HttpResponse(
  783
+                '<!DOCTYPE html><html><head><title></title></head><body>'
  784
+                '<script type="text/javascript">opener.dismissAddAnotherPopup(window, "%s", "%s");</script></body></html>' % \
783 785
                 # escape() calls force_unicode.
784 786
                 (escape(pk_value), escapejs(obj)))
785 787
         elif "_addanother" in request.POST:
5  django/contrib/admin/static/admin/js/admin/RelatedObjectLookups.js
@@ -74,11 +74,12 @@ function dismissAddAnotherPopup(win, newId, newRepr) {
74 74
     var name = windowname_to_id(win.name);
75 75
     var elem = document.getElementById(name);
76 76
     if (elem) {
77  
-        if (elem.nodeName == 'SELECT') {
  77
+        var elemName = elem.nodeName.toUpperCase();
  78
+        if (elemName == 'SELECT') {
78 79
             var o = new Option(newRepr, newId);
79 80
             elem.options[elem.options.length] = o;
80 81
             o.selected = true;
81  
-        } else if (elem.nodeName == 'INPUT') {
  82
+        } else if (elemName == 'INPUT') {
82 83
             if (elem.className.indexOf('vManyToManyRawIdAdminField') != -1 && elem.value) {
83 84
                 elem.value += ',' + newId;
84 85
             } else {

0 notes on commit 6d39cb4

Please sign in to comment.
Something went wrong with that request. Please try again.