From dd8d8913ef2868adeba0bdaaed2312786847c8b7 Mon Sep 17 00:00:00 2001 From: acekat Date: Tue, 12 Apr 2016 15:08:57 +0200 Subject: [PATCH] avoid error on editorDestroy and editorSetup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In my case I share one instance of MediumEditor between différent DOM elements and some of these elements have the InsertPlugin initialized and others don't. So when you destroy/setup the MediumEditor instance, it fails at disabling/enabling the InsertPlugin for the elements that don't have the plugin initialized ($(el).data('plugin_' + pluginName) is undefined). --- src/js/core.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/js/core.js b/src/js/core.js index 83c52d1d0..628315b84 100644 --- a/src/js/core.js +++ b/src/js/core.js @@ -158,7 +158,9 @@ Core.prototype.editorDestroy = function () { $.each(this.elements, function (key, el) { - $(el).data('plugin_' + pluginName).disable(); + if ($(el).data('plugin_' + pluginName) instanceof Core) { + $(el).data('plugin_' + pluginName).disable(); + } }); this._destroy(); @@ -174,7 +176,9 @@ this._setup(); $.each(this.elements, function (key, el) { - $(el).data('plugin_' + pluginName).enable(); + if ($(el).data('plugin_' + pluginName) instanceof Core) { + $(el).data('plugin_' + pluginName).enable(); + } }); };