Veg*_*kui 4 html javascript ckeditor
因为我使用CKEditor(http://ckeditor.com/),我遇到了问题.问题是我找不到编辑ReadOnly的方法,因为我想保持一致性,所以我不能只使用textarea.我已经在StackOwerflow上看到过很多这样的问题,但是它们都没有工作或者太旧了.
到目前为止我的代码只是显示/初始化编辑器:
$(document).ready(function(){
CKEDITOR.replace( 'ckeditor', {
on: {
// 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();
}
}
});
});
Run Code Online (Sandbox Code Playgroud)
我使用最新的CKEditor版本(v.4.1.1完整包)
提前致谢!:)
在docs readOnly中,您可以将配置设置为readOnly
config.readOnly = true;
Run Code Online (Sandbox Code Playgroud)
还有一个示例显示通过方法设置它
editor.setReadOnly( true);
Run Code Online (Sandbox Code Playgroud)
尝试以下几行,
<textarea id="editor1" name="editor1" ></textarea>
<textarea id="editor2" name="editor2" ></textarea>
<input type="button" onclick="EnableEditor2()" value="EnableEditor2" />
<script>
$(document).ready(function () {
//set editor1 readonly
CKEDITOR.replace('editor1', {readOnly:true});
CKEDITOR.replace('editor2');
//set editor2 readonly
CKEDITOR.instances.editor2.config.readOnly = true;
});
function EnableEditor2() {
CKEDITOR.instances.editor2.setReadOnly(false);
}
</script>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14739 次 |
| 最近记录: |