Django

Code

Ticket #106 (reopened)

Opened 3 years ago

Last modified 7 months ago

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

Reported by: paolo Assigned to: nobody
Component: Admin interface Version:
Keywords: Cc:
Triage Stage: Accepted Has patch: 1
Needs documentation: 0 Needs tests: 0
Patch needs improvement: 1

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

RelatedObjectLookups.js.patch (1.1 kB) - added by paolo <paolo@php3.it> on 09/22/05 06:04:19.
patch

Change History

09/22/05 06:04:19 changed by paolo <paolo@php3.it>

  • attachment RelatedObjectLookups.js.patch added.

patch

09/22/05 06:11:00 changed by paolo <paolo@php3.it>

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
+}

09/22/05 08:03:56 changed by adrian

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

09/25/05 17:29:34 changed by jacob

  • owner changed from adrian to jacob.
  • status changed from new to assigned.
  • milestone set to Version 1.0.

09/29/05 08:02:35 changed by jacob

  • status changed from assigned to closed.
  • resolution set to fixed.

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

08/29/06 14:57:08 changed by ubernostrum

  • status changed from closed to reopened.
  • resolution deleted.

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.

01/17/07 16:12:17 changed by

  • milestone deleted.

Milestone Version 1.0 deleted

07/15/07 00:23:40 changed by gwilson

  • stage changed from Ready for checkin to Accepted.

Not ready for checkin, no patch for hyphen issue.

10/12/07 13:47:12 changed by ubernostrum

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


Add/Change #106 ([patch] Problem with some js/select box on IE )




Change Properties
Action