0
votes

I use this code to make ckeditor readonly:

( function()
{
   var cancelEvent = function( evt )
      {
         evt.cancel();
      };

   CKEDITOR.editor.prototype.readOnly = function( isReadOnly )
   {
      // Turn off contentEditable.
        this.element.$.disabled = isReadOnly;
        this.element.$.contentEditable = !isReadOnly;
        this.element.$.designMode = isReadOnly ? "off" : "on";

      // Prevent key handling.
      this[ isReadOnly ? 'on' : 'removeListener' ]( 'key', cancelEvent, null, null, 0 );
      this[ isReadOnly ? 'on' : 'removeListener' ]( 'selectionChange', cancelEvent, null, null, 0 );

      // Disable all commands in wysiwyg mode.
      var command,
         commands = this._.commands,
         mode = this.mode;

      for ( var name in commands )
      {
         command = commands[ name ];
         isReadOnly ? command.disable() : command[ command.modes[ mode ] ? 'enable' : 'disable' ]();
         this[ isReadOnly ? 'on' : 'removeListener' ]( 'state', cancelEvent, null, null, 0 );
      }
   }
} )();

After this I use this code:

  $(document).ready(function () {
         $("#status_news1").click(function () {
             if (document.getElementById("status_news1").selectedIndex == 0 || document.getElementById("status_news1").selectedIndex == 2) {
                 CKEDITOR.instances.content1.readOnly( true ); 
             }
             else {
                 CKEDITOR.instances.content1.readOnly( false );
             }
         });

     });

The problem is that I have this error : CKEDITOR.instances.content1.readOnly is not a function . How can I solve this error? How can I change the state of readonly by using the select element "status_news1"?

1

1 Answers

0
votes

The API already provides a method: setReadOnly