From f4072f5be8477fdba485d9594c0c3ce2aca1d11b Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Sat, 11 Apr 2009 11:32:50 +0000 Subject: [PATCH] Fixed #10782 -- Fixed a Javascript error in the admin. Viewing an empty changelist page no longer attempts to attach event listeners to an undefined object. git-svn-id: http://code.djangoproject.com/svn/django/trunk@10515 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/contrib/admin/media/js/actions.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/django/contrib/admin/media/js/actions.js b/django/contrib/admin/media/js/actions.js index 4f8050d844..d34488ab9d 100644 --- a/django/contrib/admin/media/js/actions.js +++ b/django/contrib/admin/media/js/actions.js @@ -8,15 +8,17 @@ var Actions = { }); } var changelistTable = document.getElementsBySelector('#changelist table')[0]; - addEvent(changelistTable, 'click', function(e) { - if (!e) { var e = window.event; } - var target = e.target ? e.target : e.srcElement; - if (target.nodeType == 3) { target = target.parentNode; } - if (target.className == 'action-select') { - var tr = target.parentNode.parentNode; - Actions.toggleRow(tr, target.checked); - } - }); + if (changelistTable) { + addEvent(changelistTable, 'click', function(e) { + if (!e) { var e = window.event; } + var target = e.target ? e.target : e.srcElement; + if (target.nodeType == 3) { target = target.parentNode; } + if (target.className == 'action-select') { + var tr = target.parentNode.parentNode; + Actions.toggleRow(tr, target.checked); + } + }); + } }, toggleRow: function(tr, checked) { if (checked && tr.className.indexOf('selected') == -1) {