You Are Here: Home » How-To » Programming

How To Get Textarea Content Value Of NicEdit WYSIWYG Editor?

By Debjit on October 14th, 2012 
Advertisement

NicEdit WYSIWYG editor is one the best and smallest (code wise) WYSIWYG editors for the web out there. It has a very small code foot print and with just two lines of code you can convert any textarea element on you website in a nice looking rich text editor. NicEdit works on any element and not only textarea.

nicedit Logo

nicedit Logo

However, while using NicEdit on a textarea, you will have to take some other step in order to get the content of the textarea - as to whatever the user has entered. You may think, you can easily get the content entered in the textarea WYSIWYG editor of NicEdit in two ways:

Using jQuery

var notes = $("div.nicEdit-main").html();

For this method to work you have to make sure that you have jQuery defined in your website / web app's sources. The value of the content in the textarea will be available in the notes variable above.

Using nicEdit Libraries

This method does not need jQuery to be included and works purely based on nicEdit's helper libraries that you have already included in order to initialize the nicEdit WYSIWYG editor on the desired textarea:

var nicInstance = nicEditors.findEditor('myID');

here, myID is the element ID pertaining to the textarea, for eg.

<textarea id="myID"></textarea>

Now that, we have instantiated our editor, we can get its contents using this code snippet:

var notes = nicInstance.getContent();

Please let us know if you are facing any issues with nicEditor we can help you out.

Advertisement







How To Get Textarea Content Value Of NicEdit WYSIWYG Editor? was originally published on Digitizor.com on October 14, 2012 - 11:23 am (Indian Standard Time)