From e34f56dcc6a2adffd7bea818ebc61edb5384d7f4 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Mon, 9 Jan 2012 13:20:11 +0100 Subject: [PATCH] MINOR Better failsafes for tree hints (allows add if hint for class is if not defined) --- javascript/CMSMain.AddForm.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/javascript/CMSMain.AddForm.js b/javascript/CMSMain.AddForm.js index 24536d05..0ebc6a80 100644 --- a/javascript/CMSMain.AddForm.js +++ b/javascript/CMSMain.AddForm.js @@ -44,8 +44,11 @@ metadata = this.find('#ParentID .TreeDropdownField').data('metadata'), id = this.find('#ParentID .TreeDropdownField').getValue(), newClassName = metadata ? metadata.ClassName : null, - disallowedChildren = hints[newClassName ? newClassName : 'Root'].disallowedChildren || [], - defaultChildClass = hints[newClassName ? newClassName : 'Root'].defaultChild || null; + hintKey = newClassName ? newClassName : 'Root', + hint = (typeof hints[hintKey] != 'undefined') ? hints[key] : null; + + var disallowedChildren = (hint && typeof hint.disallowedChildren != 'undefined') ? hint.disallowedChildren : [], + defaultChildClass = (hint && typeof hint.defaultChild != 'undefined') ? hint.defaultChild : null; // Limit selection this.find('#PageType li').each(function() {