最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - how to set nicedit uneditable - Stack Overflow

programmeradmin5浏览0评论

i'm using nicedit js which is is a WYSIWYG editor in my textarea to view html doc, but it still editable, how to set this nicedit to readonly mode, i try to search from its doc but unable to find it, do any one have experience using nicedit,

thanks in advance

i'm using nicedit js which is is a WYSIWYG editor in my textarea to view html doc, but it still editable, how to set this nicedit to readonly mode, i try to search from its doc but unable to find it, do any one have experience using nicedit,

thanks in advance

Share Improve this question edited Nov 26, 2010 at 4:17 Apache asked Nov 26, 2010 at 3:58 ApacheApache 1,8069 gold badges51 silver badges72 bronze badges
Add a ment  | 

7 Answers 7

Reset to default 7

Here is a helpful jQuery solution that I use with nicEdit:

jQuery('.nicEdit-main').attr('contenteditable','false');
jQuery('.nicEdit-panel').hide();

You can simply change it back to 'true' to make it editable again.

Note: I would consider toggling the div background-color along with this solution.

finally the solution is

var myNicEditor = new nicEditor(); myNicEditor.addInstance('templateContent'); nicEditors.findEditor("templateContent").disable();

With the statement nicEditors.findEditor("TextArea").disable(); niceditor is non editable But

nicEditors.findEditor("TextArea").attr("contentEditable","true");

does not make it editable again

for me only this worked:

document.getElementsByClassName('nicEdit-main')[0].removeAttribute('contentEditable');

I'm going to guess it is a WYSIWYG editor.

Try this...

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();

above statement will disable the TextArea.

For enabling the TextArea, update the nicEdit.js (see below what to update)

search for disable: function () { this.elm.setAttribute("contentEditable", "false"); }

next to this code add the below code

, enable: function () { this.elm.setAttribute("contentEditable", "true"); }

and in your JavaScript call nicEditors.findEditor("TextArea").enable();

发布评论

评论列表(0)

  1. 暂无评论