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

Commit de852d2

Browse files
committed
Merge pull request #8 from jrust/patch-1
Allow null model value and ensure tinymce is instantiated
2 parents 3f2abcf + ea291b3 commit de852d2

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/tinymce.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ angular.module('ui.tinymce', [])
3838
},
3939
// Update model when calling setContent (such as from the source editor popup)
4040
setup: function (ed) {
41+
ed.onInit.add(function(ed) {
42+
ngModel.$render();
43+
});
4144
ed.onSetContent.add(function (ed, o) {
4245
if (ed.isDirty()) {
4346
ed.save();
@@ -60,11 +63,15 @@ angular.module('ui.tinymce', [])
6063
setTimeout(function () {
6164
tinymce.init(options);
6265
});
63-
ngModel.$render = function(){
66+
67+
68+
ngModel.$render = function() {
6469
if (!tinyInstance) {
6570
tinyInstance = tinymce.get(attrs.id);
6671
}
67-
tinyInstance.setContent(ngModel.$viewValue);
72+
if (tinyInstance) {
73+
tinyInstance.setContent(ngModel.$viewValue || '');
74+
}
6875
};
6976
}
7077
};

0 commit comments

Comments
 (0)