【发布时间】:2014-10-20 16:00:04
【问题描述】:
现在,我正在使用这行代码来禁用 tinyMCE
tinyMCE.get('tinymce_id').getBody().setAttribute('contenteditable', false);
但是,它似乎并没有在初始化时被禁用。只有当我选择单选按钮时,它才会被禁用。
如何在初始化后禁用特定的 tinyMCE 编辑器?如果可能的话,我想要一个也适用于 IE8 的答案。提前致谢!
jQuery :
require(['tinymce'],function(){
var disableInputs = function(){
if($('input[name=type]:checked').val()==1){
tinyMCE.get('newsletter_message').getBody().setAttribute('contenteditable', false);
tinyMCE.get('category_message').getBody().setAttribute('contenteditable', true);
}else{
tinyMCE.get('newsletter_message').getBody().setAttribute('contenteditable', true);
tinyMCE.get('category_message').getBody().setAttribute('contenteditable', false);
}
};
$('input[name=type]').on('click',function(){
disableInputs();
});
disableInputs();
});
HTML:
<input type="radio" value=1 name=type/>
<div id="newsletter"> tinymce with id of newsletter_message initializes here... </div>
<input type="radio" value=0 name=type/>
<div id="category"> tinymce with id of category_message initializes here... </div>
【问题讨论】:
-
tinyMCE.remove();? -
@KevinLabécot 你确定吗?我不想删除它。只想禁用它。
-
好吧,好吧。我错了;)
标签: javascript jquery html tinymce