From 0f8c0b7cea878d279484cddd5b01925d2ad75f4f Mon Sep 17 00:00:00 2001 From: azivner Date: Sun, 27 Aug 2017 14:44:12 -0400 Subject: [PATCH] fix JS errors comming from resize when fancytree and summernote isn't initialized yet --- static/js/init.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/static/js/init.js b/static/js/init.js index 08077a490..78695d207 100644 --- a/static/js/init.js +++ b/static/js/init.js @@ -1,7 +1,16 @@ $(function() { $(window).resize(function() { - $('ul.fancytree-container').height($(window).height() - $('ul.fancytree-container').offset().top - 10); - $('div.note-editable').height($(window).height() - $('div.note-editable').offset().top); + const fancyTree = $('ul.fancytree-container'); + + if (fancyTree.length) { + fancyTree.height($(window).height() - fancyTree.offset().top - 10); + } + + const noteEditable = $('div.note-editable'); + + if (noteEditable.length) { + noteEditable.height($(window).height() - noteEditable.offset().top); + } }); $(window).resize(); });