我正在使用nicedit js,它是我的文本区域中的WYSIWYG编辑器,用于查看html文档,但仍可编辑,如何将nicedit设置为只读模式,我尝试从其文档中搜索但找不到它,执行任何人都有使用nicedit的经验,
预先感谢
这是我与nicEdit一起使用的有用的jQuery解决方案:
jQuery('.nicEdit-main').attr('contenteditable','false');
jQuery('.nicEdit-panel').hide();
您可以简单地将其更改回'true',使其再次可编辑。
注意:我会考虑与此解决方案一起切换div背景色。
最终解决方案是
var myNicEditor = new nicEditor();myNicEditor.addInstance('templateContent');nicEditors.findEditor(“ templateContent”)。disable();
带有语句nicEditors.findEditor("TextArea").disable(); niceditor
不可编辑但是
nicEditors.findEditor("TextArea").attr("contentEditable","true");
不会再次使其变为可编辑状态
仅对我来说这有效:
document.getElementsByClassName('nicEdit-main')[0].removeAttribute('contentEditable');
我猜它是所见即所得的编辑器。
尝试一下...
document.getElementById('nicedit').removeAttribute('contentEditable');
function edit(){
a = new nicEditor({fullPanel:true})。panelInstance('area5',{hasPanel:true});;}
function no_edit(){
a.removeInstance('area5');}
nicEditors.findEditor(“ TextArea”)。disable();
上面的语句将禁用TextArea。
要启用TextArea,请更新nicEdit.js(请参阅下面的更新内容)
搜索disable:function(){this.elm.setAttribute(“ contentEditable”,“ false”); }
在此代码旁边添加以下代码
enable:function(){this.elm.setAttribute(“ contentEditable”,“ true”); }
以及您的JavaScript调用nicEditors.findEditor(“ TextArea”)。enable();] >>