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

Commit ea291b3

Browse files
author
Jason Rust
committed
Using tinymce.onInit to ensure content gets set after tinymce is set up
1 parent b1eb447 commit ea291b3

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/tinymce.js

Lines changed: 9 additions & 8 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();
@@ -61,17 +64,15 @@ angular.module('ui.tinymce', [])
6164
tinymce.init(options);
6265
});
6366

64-
var interval = setInterval(function (){
65-
tinyInstance = tinymce.get(attrs.id);
6667

68+
ngModel.$render = function() {
69+
if (!tinyInstance) {
70+
tinyInstance = tinymce.get(attrs.id);
71+
}
6772
if (tinyInstance) {
68-
clearInterval(interval);
69-
70-
ngModel.$render = function() {
71-
tinyInstance.setContent(ngModel.$viewValue || '');
72-
};
73+
tinyInstance.setContent(ngModel.$viewValue || '');
7374
}
74-
}, 0);
75+
};
7576
}
7677
};
7778
}]);

0 commit comments

Comments
 (0)