From 828359e52dd8f190a577442a88517e1ba9ba8da0 Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Wed, 17 Jul 2013 09:32:14 -0400 Subject: [PATCH] Couple of cleanups in RelatedObjectLookups.js Thanks George Karpenkov. --- .../admin/static/admin/js/admin/RelatedObjectLookups.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/django/contrib/admin/static/admin/js/admin/RelatedObjectLookups.js b/django/contrib/admin/static/admin/js/admin/RelatedObjectLookups.js index 6d1748663e..c82c8c05cb 100644 --- a/django/contrib/admin/static/admin/js/admin/RelatedObjectLookups.js +++ b/django/contrib/admin/static/admin/js/admin/RelatedObjectLookups.js @@ -55,7 +55,7 @@ function dismissRelatedLookupPopup(win, chosenId) { function showAddAnotherPopup(triggeringLink) { var name = triggeringLink.id.replace(/^add_/, ''); name = id_to_windowname(name); - href = triggeringLink.href + var href = triggeringLink.href; if (href.indexOf('?') == -1) { href += '?_popup=1'; } else { @@ -73,10 +73,11 @@ function dismissAddAnotherPopup(win, newId, newRepr) { newRepr = html_unescape(newRepr); var name = windowname_to_id(win.name); var elem = document.getElementById(name); + var o; if (elem) { var elemName = elem.nodeName.toUpperCase(); if (elemName == 'SELECT') { - var o = new Option(newRepr, newId); + o = new Option(newRepr, newId); elem.options[elem.options.length] = o; o.selected = true; } else if (elemName == 'INPUT') { @@ -88,8 +89,7 @@ function dismissAddAnotherPopup(win, newId, newRepr) { } } else { var toId = name + "_to"; - elem = document.getElementById(toId); - var o = new Option(newRepr, newId); + o = new Option(newRepr, newId); SelectBox.add_to_cache(toId, o); SelectBox.redisplay(toId); }