Search code examples
javascriptangularjsckeditor

How to Update the Ck edior content on each response


CK editor initialization 
    function initEditor(){  

            CKEDITOR.replace( 'editor1', {

                on: {
                    //focus: onFocus,
                    //blur: onBlur,

                    // Check for availability of corresponding plugins.
                    pluginsLoaded: function( evt ) {
                        var doc = CKEDITOR.document, ed = evt.editor;
                        if ( !ed.getCommand( 'bold' ) )
                            doc.getById( 'exec-bold' ).hide();
                        if ( !ed.getCommand( 'link' ) )
                            doc.getById( 'exec-link' ).hide();
                    }
                }
            });
        }


function getIndividualReportData( reportId ){
        ReportService.getIndividualReportList( reportId ,
                function( data ) // success
                {
                    console.log(data);
                    $scope.report = data ;

                    initEditor();


                },
                function( msg ) // error
                {

                });

    }

html-ck editor

<textarea cols="100"  name="editor1" rows="50" data-ng-model="report.reportData">

            {{ report.reportData }}
        </textarea>

But data is not updating in ck editor.Initilazing CK editor after getting response then it showing the data .But if i am calling the function initEditor ,then it showing the warning The editor instance "editor1" is already attached to the provided element.

I am using angular js + Ck editor


Solution

  • got the answer

    I have to clear the instance

    delete CKEDITOR.instances[ 'editor1' ];