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
This commit is contained in:
Sean Harvey 2009-05-06 05:53:22 +00:00
parent 4389affa5c
commit b1b07c5325

View File

@ -97,8 +97,14 @@ Behaviour.register({
// ParentType / ParentID field combination // ParentType / ParentID field combination
'#Form_EditForm_ParentType' : { '#Form_EditForm_ParentType' : {
initialize : function() { initialize : function() {
$('Form_EditForm_ParentType_root').onclick = this.rootClick.bind(this); var parentTypeRootEl = $('Form_EditForm_ParentType_root');
$('Form_EditForm_ParentType_subpage').onclick = this.showHide; var parentTypeSubpageEl = $('Form_EditForm_ParentType_subpage');
if(parentTypeRootEl) {
parentTypeRootEl.onclick = this.rootClick.bind(this);
}
if(parentTypeSubpageEl) {
parentTypeSubpageEl.onclick = this.showHide;
}
this.showHide(); this.showHide();
}, },
@ -108,7 +114,8 @@ Behaviour.register({
}, },
showHide : function() { showHide : function() {
if($('Form_EditForm_ParentType_root').checked) { var parentTypeRootEl = $('Form_EditForm_ParentType_root');
if(parentTypeRootEl && parentTypeRootEl.checked) {
Element.hide('ParentID'); Element.hide('ParentID');
} else { } else {
Element.show('ParentID'); Element.show('ParentID');