Reputation: 15420
I am adding textboxes dynamically to a div. Something likhe this
$('#xyz').click(function()
{
$(#myDiv).append('<textarea></textarea>');
});
Now I want to attach tinymce editor to these textareas, Can you help me in doing this?
Upvotes: 2
Views: 1432
Reputation: 50832
You could even attach the tinymce element to the div directly, because you don't need a textarea in order to edit and submit text using a tinymce editor instance. Tinymce will create an editable iframe in the dom in which the user is able to edit html content. OnSave the editors content gets written back to the html element the tinymce editor was created for (this can be a textarea, a div, a paragraph or another html elment).
tinyMCE.execCommand('mceAddControl', false, 'myDiv');
Upvotes: 2
Reputation: 337550
Try this:
$('#xyz').click(function() {
var myTextarea = $("<textarea></textarea>");
myTextarea.attr("id", "mce-editor");
$("#myDiv").append(myTextarea);
// this inistalises the TinyMCE editor upon the element with the id in the last parameter.
tinyMCE.execCommand("mceAddControl", false, "mce-editor");
});
Upvotes: 3