I have a little problem with adding tinymce dynamically to textarea after init.
tinymce.init({
selector: "textarea",
theme: "modern",
height: 100,
plugins: [
"advlist autolink image lists charmap print preview hr anchor pagebreak spellchecker",
"link searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking",
"save table contextmenu directionality emoticons template paste textcolor"
],
toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | l ink image | print preview media fullpage | forecolor backcolor emoticons",
style_formats: [
{title: 'Bold text', inline: 'b'},
{title: 'Red text', inline: 'span', styles: {color: '#ff0000'}},
{title: 'Red header', block: 'h1', styles: {color: '#ff0000'}},
{title: 'Example 1', inline: 'span', classes: 'example1'},
{title: 'Example 2', inline: 'span', classes: 'example2'},
{title: 'Table styles'},
{title: 'Table row 1', selector: 'tr', classes: 'tablerow1'}
]
});
And my button to add new textarea:
$('#add_new_text').click(function(){
var n = 1;
$( '<textarea class="cla" name="text'+n+'"></textarea>' ).appendTo( '#wrap_f' );
n++;
})
I've tried to do this tinyMCE.execCommand('mceAddControl', false, '');
But it didn't work.
Have you tried calling tinymce.init
function after the appendTo function?
jQuery functions operates synchronously, one at a time. That means, your init function will run after the appentTo
completes, and that means, you don't need a callback for that.
Just write your tinymce.init
funtion after the appendTo
and get back here to tell the result :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With