Skip to content

Commit ee17cae

Browse files
committed
Fix: Wait until textarea is attached before ckeditor
1 parent 9cf4a03 commit ee17cae

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

frontend/src/modules/scaffold/backboneFormsOverrides.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,20 @@ define([
6666
Backbone.Form.editors.TextArea.prototype.render = function() {
6767
textAreaRender.call(this);
6868

69-
_.defer(function() {
69+
function until(conditionFunction) {
70+
const poll = resolve => {
71+
if(conditionFunction()) resolve();
72+
else setTimeout(_ => poll(resolve), 400);
73+
}
74+
return new Promise(poll);
75+
}
76+
function isAttached($element) {
77+
return function() {
78+
return Boolean($element.parents('body').length);
79+
};
80+
}
81+
82+
until(isAttached(this.$el)).then(function() {
7083
this.editor = CKEDITOR.replace(this.$el[0], {
7184
dataIndentationChars: '',
7285
disableNativeSpellChecker: false,

0 commit comments

Comments
 (0)