Skip to content

Commit 688fde7

Browse files
fix for the #110
1 parent 7845c96 commit 688fde7

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/ck-editor.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,25 @@ function init(Survey) {
1919
});
2020
},
2121
afterRender: function(question, el) {
22+
var name = question.name;
2223
CKEDITOR.editorConfig = function(config) {
2324
config.language = "es";
2425
config.height = question.height;
2526
config.toolbarCanCollapse = true;
2627
};
28+
el.name = name;
29+
30+
if (CKEDITOR.instances[name]) {
31+
CKEDITOR.instances[name].removeAllListeners();
32+
CKEDITOR.remove(CKEDITOR.instances[name]);
33+
}
34+
2735
var editor = CKEDITOR.replace(el);
28-
CKEDITOR.instances.editor1.config.readOnly = question.isReadOnly;
36+
CKEDITOR.instances[name].config.readOnly = question.isReadOnly;
2937

3038
var isValueChanging = false;
3139
var updateValueHandler = function() {
32-
if (isValueChanging) return;
40+
if (isValueChanging || typeof question.value === "undefined") return;
3341
editor.setData(question.value);
3442
};
3543
editor.on("change", function() {
@@ -50,6 +58,8 @@ function init(Survey) {
5058
},
5159
willUnmount: function(question, el) {
5260
question.readOnlyChangedCallback = null;
61+
CKEDITOR.instances[name].removeAllListeners();
62+
CKEDITOR.remove(CKEDITOR.instances[name]);
5363
}
5464
};
5565

0 commit comments

Comments
 (0)