Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set Html Content in TinyMCE

I am working on eCommerce Project where Html text editor is needed and i choose TinyMCE. TinyMCE is nice editor for editing text.

I use Asp.net MVC4 and mysql database for storing data of tinyMCE. I am easily able to get the content of tinyMCE editor By using

tinymce.get("textfull").getContent({ format: 'raw' }).replace(/</g, "&lt;").replace(/>/g, "&gt;");

this code provide me HTML encoded text but i want to show this text on new tinyMCE Editor by using this code

tinymce.get("textfull").setContent($("<div/>").html(d.Description).text());

but this code set html Text not Html rendered content on browser TinyMCE Result

Please tell me what is the correct way to show as HTML Element not text.

like image 885
NorCode Avatar asked Jan 11 '16 08:01

NorCode


People also ask

How do you get content in TinyMCE with HTML tags?

The TinyMCE getContent and setContent methods You can do this using the getContent() API method. Let's say you have initialized the editor on a textarea with id=”myTextarea”. This will return the content in the editor marked up as HTML.

How do I save HTML content of TinyMCE into a file?

To save the page, you have to insert TinyMCE in a HTML form and add a submit button. Then you'll have to handle the submitted form with a language like PHP. A call to the file_put_contents() function should do it.

How do you replace content in TinyMCE?

Here is the code that will replace your editor content. But you will need to do this action at the correct time. var editor = tinyMCE. get('my_editor_id'); also works.


1 Answers

You could try

tinymce.get("textfull").getBody().innerHTML = $("").html(d.Description).text();

or

tinymce.get("textfull").getBody().innerHTML = d.Description;
like image 177
Thariama Avatar answered Sep 28 '22 03:09

Thariama