0

I'm having a hard time using setReadonly of CKEDITOR. I want to use setReadonly when the Editor is already loaded and ready to be used. I tried using instanceReady:

    var editor;
    CKEDITOR.on( 'instanceReady', function( ev ){
        editor = ev.editor;
        editor.setReadOnly( true );
    });     

but this does not work, I tried using buttons like the sample is using and it works fine. Is there anyway to setReadonly automatically when the editor is ready to be used?

Thanks

4

3 回答 3

2

最好将它创建为只读而不是等待它完成然后告诉它以只读方式重新启动。

例如

<!DOCTYPE html>
<html>
<head>
  <script type="text/javascript" src="ckeditor/ckeditor.js"></script>
</head>
<body>
<textarea name="messageid" id="messageid">
    abc
</textarea>
<script type="text/javascript">
   CKEDITOR.replace('messageid', {readOnly: true} );  
 </script>   
</body>
</html>

小提琴演示

于 2012-05-10T18:01:22.677 回答
2

在这里你可以看到它是如何工作的!!对我来说工作正常。

http://ckeditor.com/latest/samples/readonly.html

于 2012-10-25T15:46:58.620 回答
1

很简单,在 textarea 中使用 disabled 标签。

例子:

<!DOCTYPE html>
<html>
<head>
  <script type="text/javascript" src="ckeditor/ckeditor.js"></script>
</head>
<body>
<textarea name="messageid" id="messageid" disabled="disabled">
    abc
</textarea>
<script type="text/javascript">
   CKEDITOR.replace('messageid');  
 </script>   
</body>
</html>
于 2014-11-21T19:34:02.357 回答