From 6f81c3472e07ac567938a0d5fc7b5421b9fa49c5 Mon Sep 17 00:00:00 2001 From: Riyyi Date: Wed, 3 Mar 2021 19:56:36 +0100 Subject: [PATCH] Dont try to load CodeMirror on non-existent DOM element --- app/views/partials/script.php | 2 +- public/js/app.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/partials/script.php b/app/views/partials/script.php index 78e5aeb..a30d14b 100644 --- a/app/views/partials/script.php +++ b/app/views/partials/script.php @@ -1,7 +1,7 @@ - + adminSection) { ?> diff --git a/public/js/app.js b/public/js/app.js index 01ba676..90006bb 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -104,13 +104,13 @@ $(document).ready(function() { // Enable CodeMirror Editor $.fn.codeMirror = function() { + if (this.length === 0) return; + editor = CodeMirror.fromTextArea($(this)[0], editorOptions); editor.setSize('100%', '500'); registerEditorCopy(); - - return editor; } - $('textarea#syntax-code').codeMirror().setOption('mode', 'text/x-csrc'); + $('textarea#syntax-code').codeMirror(); // Enable WYSIWYG Editor $('textarea#summernote').summernote({