From b1b07c532518443ea693dee2f966c73a21936230 Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Wed, 6 May 2009 05:53:22 +0000 Subject: [PATCH] BUGFIX Fixed scenarios where the page is readonly and the expected ParentType elements don't exist causing a JS error git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@76258 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- javascript/CMSMain_right.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/javascript/CMSMain_right.js b/javascript/CMSMain_right.js index de246c55..453cc6de 100755 --- a/javascript/CMSMain_right.js +++ b/javascript/CMSMain_right.js @@ -97,8 +97,14 @@ Behaviour.register({ // ParentType / ParentID field combination '#Form_EditForm_ParentType' : { initialize : function() { - $('Form_EditForm_ParentType_root').onclick = this.rootClick.bind(this); - $('Form_EditForm_ParentType_subpage').onclick = this.showHide; + var parentTypeRootEl = $('Form_EditForm_ParentType_root'); + var parentTypeSubpageEl = $('Form_EditForm_ParentType_subpage'); + if(parentTypeRootEl) { + parentTypeRootEl.onclick = this.rootClick.bind(this); + } + if(parentTypeSubpageEl) { + parentTypeSubpageEl.onclick = this.showHide; + } this.showHide(); }, @@ -108,7 +114,8 @@ Behaviour.register({ }, showHide : function() { - if($('Form_EditForm_ParentType_root').checked) { + var parentTypeRootEl = $('Form_EditForm_ParentType_root'); + if(parentTypeRootEl && parentTypeRootEl.checked) { Element.hide('ParentID'); } else { Element.show('ParentID');