diff --git a/package.json b/package.json index 312f298..3d5d4e1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-ui-tinymce", - "version": "0.0.18", + "version": "0.0.19", "descriptin": "This directive allows you to add a tinymce to your form elements.", "author": "https://github.com/angular-ui/ui-tinymce/graphs/contributors", "license": "MIT", diff --git a/src/tinymce.js b/src/tinymce.js index c0291af..e51b7af 100644 --- a/src/tinymce.js +++ b/src/tinymce.js @@ -179,7 +179,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(); @@ -189,6 +189,7 @@ angular.module('ui.tinymce', []) clonedElement.removeAttr('aria-hidden'); tinymce.execCommand('mceRemoveEditor', false, eid); parentElement.append($compile(clonedElement)(scope)); + unbindEventListener(); } });