Opened 10 years ago

Closed 7 years ago

Last modified 7 years ago

#106 closed defect (fixed)

[patch] Problem with some js/select box on IE

Reported by: paolo Owned by: kmtracey
Component: contrib.admin Version:
Severity: normal Keywords:
Cc: nowellpublic@… Triage Stage: Accepted
Has patch: yes Needs documentation: yes
Needs tests: yes Patch needs improvement: yes
Easy pickings: UI/UX:

Description

Extract from Tutorial 1: 'When you click "Add Another," you'll get a popup window with the "Add poll" form. If you add a poll in that window and click "Save," Django will save the poll to the database and dynamically add it as the selected choice on the "Add choice" form you're looking at.'

This (dynamically add it) works on Mozilla 1.0.4 Win. It is not true on IE 6. A blank string is shown instead of name of the new poll. Just after a manual refresh of the page things appear correctly.

Attachments (2)

RelatedObjectLookups.js.patch (1.1 KB) - added by paolo <paolo@…> 10 years ago.
patch
patch.diff (1.9 KB) - added by nbstrite 7 years ago.
This patch fixes the issue that dashes and dots cause for IE6+

Download all attachments as: .zip

Change History (15)

Changed 10 years ago by paolo <paolo@…>

patch

comment:1 Changed 10 years ago by paolo <paolo@…>

I had the needing to solve this, so I have investigate on it.
The issue happen using IE, when foreignkeys fields are contained inside fieldsets. 1) Clicking on 'Add another' icon it doesn't open another window, but just display the new page in the same window; 2) when the new item is added as a new option, it is displayed at the last item of the select box as a blank string; 3) it is not shown as selected.

The attached patch works for me. I hope that it could solve this problems for other people too without any breakage. Thanks.

Index: django/conf/admin_media/js/admin/RelatedObjectLookups.js
===================================================================
--- django/conf/admin_media/js/admin/RelatedObjectLookups.js    (revision 661)
+++ django/conf/admin_media/js/admin/RelatedObjectLookups.js    (working copy)
@@ -20,19 +20,21 @@

 function showAddAnotherPopup(triggeringLink) {
     var name = triggeringLink.id.replace(/^add_/, '');
+    name = name.replace(/\./g, '___');
     var win = window.open(triggeringLink.href + '?_popup=1', name, 'height=500,width=800,resizable=yes,scrollbars=yes');
     win.focus();
     return false;
 }

 function dismissAddAnotherPopup(win, newId, newRepr) {
-    var elem = document.getElementById(win.name);
+    var name = win.name.replace(/___/g, '.')
+    var elem = document.getElementById(name);
     if (elem.nodeName == 'SELECT') {
         var o = new Option(newRepr, newId);
-        elem.appendChild(o);
+        elem.options[elem.options.length] = o
         elem.selectedIndex = elem.length - 1;
     } else if (elem.nodeName == 'INPUT') {
         elem.value = newId;
     }
     win.close();
-}
\ No newline at end of file
+}

comment:2 Changed 10 years ago by adrian

  • Summary changed from Problem with some js/select box on IE to [patch] Problem with some js/select box on IE

comment:3 Changed 10 years ago by jacob

  • milestone set to Version 1.0
  • Owner changed from adrian to jacob
  • Status changed from new to assigned

comment:4 Changed 10 years ago by jacob

  • Resolution set to fixed
  • Status changed from assigned to closed

(In [716]) Fixed #106 - "Add another" now correctly works in IE - thanks, Paolo

comment:5 Changed 9 years ago by ubernostrum

  • Resolution fixed deleted
  • Status changed from closed to reopened

This doesn't actually fix the entire problem; IE only allows alphanumerics and underscores in window names, and Django has a habit of trying to generate these from IDs that contain hyphens.

I'll work up a more robust patch and submit it soon.

comment:6 Changed 9 years ago by anonymous

  • milestone Version 1.0 deleted

Milestone Version 1.0 deleted

comment:7 Changed 8 years ago by gwilson

  • Triage Stage changed from Ready for checkin to Accepted

Not ready for checkin, no patch for hyphen issue.

comment:8 Changed 8 years ago by ubernostrum

(In [6474]) 0.91-bugfixes: Backport [3066] and some related changes. Refs #1635, #106.

comment:9 Changed 7 years ago by anonymous

  • Needs documentation set
  • Needs tests set

comment:10 Changed 7 years ago by kmtracey

  • Owner changed from nobody to kmtracey
  • Status changed from reopened to new

#9332, #9539, #9543 all recently reported dashes in the popup window names causing problems. It seems the time has come to fix this!

Changed 7 years ago by nbstrite

This patch fixes the issue that dashes and dots cause for IE6+

comment:11 Changed 7 years ago by nbstrite

  • Cc nowellpublic@… added

I have attached the updated (good catch kmtracey) patch to resolve this issue. Reference #9539 for examples of how to recreate this bug in the admin with a simple model and admin definition.

comment:12 Changed 7 years ago by kmtracey

  • Resolution set to fixed
  • Status changed from new to closed

(In [9403]) Fixed #106 -- Refrain from generating popup window names that IE refuses to pop up. Thanks for the reports and initial patches nbstrite and jsmullyan.

comment:13 Changed 7 years ago by kmtracey

(In [9404]) [1.0.X] Fixed #106 -- Refrain from generating popup window names that IE refuses to pop up. Thanks for the reports and initial patches nbstrite and jsmullyan.

Note: See TracTickets for help on using tickets.
Back to Top