Skip to content
This repository has been archived by the owner on Sep 11, 2020. It is now read-only.

Commit

Permalink
avoid error on editorDestroy and editorSetup (#310)
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
acekat authored and linkesch committed Apr 12, 2016
1 parent 1a6228c commit cfd3009
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/js/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
}
});
};

Expand Down

0 comments on commit cfd3009

Please sign in to comment.