Reputation: 1806
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
Upvotes: 6
Views: 7076
Reputation: 1
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();
Upvotes: 0
Reputation: 677
for me only this worked:
document.getElementsByClassName('nicEdit-main')[0].removeAttribute('contentEditable');
Upvotes: 1
Reputation: 1379
function edit(){
a = new nicEditor({fullPanel : true}).panelInstance('area5',{hasPanel : true}); }
function no_edit(){
a.removeInstance('area5');
}
Upvotes: 0
Reputation: 11
With the statement
nicEditors.findEditor("TextArea").disable(); niceditor
is non editable
But
nicEditors.findEditor("TextArea").attr("contentEditable","true");
does not make it editable again
Upvotes: 1
Reputation: 4430
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.
Upvotes: 7
Reputation: 1806
finally the solution is
var myNicEditor = new nicEditor(); myNicEditor.addInstance('templateContent'); nicEditors.findEditor("templateContent").disable();
Upvotes: 3
Reputation: 490273
I'm going to guess it is a WYSIWYG editor.
Try this...
document.getElementById('nicedit').removeAttribute('contentEditable');
Upvotes: 0