我有多个Tiny MCE编辑器,我试图禁用编辑。我已经尝试的多种变化:定义同样喜欢通过jquery禁用TinyMCE文本编辑器
if(@Model.hasRegular.ToString().ToLower())
{
tinymce.get('#rte').getBody().setAttribute('contenteditable', false);
}
if(@Model.hasSmall.ToString().ToLower())
{
tinymce.get('#rteSmall').getBody().setAttribute('contenteditable', false);
}
if(@Model.isOneSize.ToString().ToLower())
{
tinymce.get('#rteOneSize').getBody().setAttribute('contenteditable', false);
}
与我的编辑都:
tinymce.init({
selector: '#rte',
toolbar: 'bold italic underline',
height: '200px',
width: '420px',
elementpath: false,
menubar: false,
content_style: "div {border: 50px solid red;}",
setup: function (ed) {
ed.on('init', function() {
this.getDoc().body.style.fontSize = '16px';
this.getDoc().body.style.fontFamily = 'Helvetica';
//disables editing for non admins
if ($('#nonAdmin').length) {
this.setMode('readonly');
}
});
}
});
目前有什么,我想,我得到一个控制台错误
:Cannot read property 'getBody' of null
检查控制台。如果有任何错误。 。 –
如果有多个,请尝试此操作。 。 tinyMCE.get('rte')。getBody()。setAttribute('contenteditable',false); –
也从版本4.3.x开始,您可以使用以下代码进行只读模式.. 其类似tinymce.activeEditor.setMode('readonly'); –