@@ -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