From c593aa8105093c4395ea12e5c1e72449aa453deb Mon Sep 17 00:00:00 2001 From: renhao Date: Wed, 29 Jun 2016 20:42:03 +0800 Subject: [PATCH] unbind efresh event when tinymce element removed --- src/tinymce.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tinymce.js b/src/tinymce.js index 1ce5c6e..4fc871b 100644 --- a/src/tinymce.js +++ b/src/tinymce.js @@ -173,7 +173,7 @@ angular.module('ui.tinymce', []) // This block is because of TinyMCE not playing well with removal and // recreation of instances, requiring instances to have different // selectors in order to render new instances properly - scope.$on('$tinymce:refresh', function(e, id) { + var unbindEventListener = scope.$on('$tinymce:refresh', function(e, id) { var eid = attrs.id; if (angular.isUndefined(id) || id === eid) { var parentElement = element.parent(); @@ -183,6 +183,7 @@ angular.module('ui.tinymce', []) clonedElement.removeAttr('aria-hidden'); tinymce.execCommand('mceRemoveEditor', false, eid); parentElement.append($compile(clonedElement)(scope)); + unbindEventListener(); } });