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

Commit b1eb447

Browse files
committed
Allow null model value and ensure tinymce is instantiated
First fix just ensures that `undefined` doesn't get passed to `setContent` because I found that `$viewValue` can be null if using ngRequired directive. Second fix uses an interval loop to keep checking for the tinymce editor object because otherwise `tinyInstance` can be undefined since `tinymce.init` is in a `setTimeout`.
1 parent 3f2abcf commit b1eb447

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/tinymce.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,18 @@ angular.module('ui.tinymce', [])
6060
setTimeout(function () {
6161
tinymce.init(options);
6262
});
63-
ngModel.$render = function(){
64-
if (!tinyInstance) {
65-
tinyInstance = tinymce.get(attrs.id);
63+
64+
var interval = setInterval(function (){
65+
tinyInstance = tinymce.get(attrs.id);
66+
67+
if (tinyInstance) {
68+
clearInterval(interval);
69+
70+
ngModel.$render = function() {
71+
tinyInstance.setContent(ngModel.$viewValue || '');
72+
};
6673
}
67-
tinyInstance.setContent(ngModel.$viewValue);
68-
};
74+
}, 0);
6975
}
7076
};
7177
}]);

0 commit comments

Comments
 (0)