1

I have a select.php page where the user selects a value from the dropdown. On selection the ajax code runs and information from ajax.php gets populated on the "display" div of the select.php page. Some of the information coming from ajax.php is in the form of textarea. But it gets displayed just as textarea, and not as tinymce editor. Even though I have called it in the head section of my page.

<script src="//cdn.tinymce.com/4/tinymce.min.js"></script>
<script>
tinymce.init({
  selector: 'textarea'
  });
</script>  

My problem is very similar to this: How do I initialize TinyMCE on a ajax loaded textarea in 4.x?

But I am not understanding the solution. Please help.

Community
  • 1
  • 1
Sachin Menon
  • 69
  • 11

2 Answers2

1

Your call to tinymce.init() only acts on items in the DOM at the time the init() function is run. If you are adding additional <textarea> fields to the page later you need to run tinymce.init() after you add those elements to the DOM.

You can include a call to tinymce.init() in the same block of code that injects the <textarea> into the page directly after you inject the <textarea>.

Michael Fromin
  • 13,131
  • 2
  • 20
  • 31
0

you can get data after that set data on tiny

success: function (data) {tinyMCE.get(data).getContent().replace('\'', "\’");},