我使用此代码使ckeditor只读:
( 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 );
}
}
} )();
在此之后我使用此代码:
$(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 );
}
});
});
问题是我有这个错误: CKEDITOR.instances.content1.readOnly不是函数。 我该如何解决这个错误?如何使用select元素“status_news1”来改变readonly的状态?