Reputation: 431
I have one Button #add_text
and DIV #appreciation
...
If I put the textarea for the TinyMCE editor directly to the html code it works
But I want to append dynamically Tinymce by clicking the button...
How to append the Tinymce Editor using jQuery's append Method?
$("#add_text").click(function(){
$("#appreciation").append("<textarea id='test' class='adtext'></textarea>");
});
The above code is not working as expected...
How can I achieve that the TinyMCE is working for the dynamically added textarea
Upvotes: 0
Views: 3946
Reputation: 1
$("#temp_Name").click(function () {
$("#temp_Description").empty();
$("#temp_Context").empty();
$.ajax({
type: 'GET',
url: '@Url.Action("insertcontext")', // we are calling json method
contentType: "application/json; charset=utf-8",
dataType: 'json',
data: { contex: $("#hidden1").val() },
success: function (edtx) {
$("#temp_Description").html("");
$("#temp_Context").html("");// clear before appending new list
$.each(edtx, function (i, city1) {
$("#temp_Description").val(city1.temp_Description);
var dataa = city1.temp_Context;
$("#temp_Context").data(city1.temp_Context);
tinymce.get("temp_Context").setContent(dataa);
//$('<option></option>').val(city1.temp_Description).html(city1.temp_Description));
});
},
error: function (ex) {
alert('Failed to retrieve states.' + ex);
}
});
return false;
})
Upvotes: 0
Reputation:
You need to init the TinyMCE to add the functionality to the new textarea after appending the textarea to the div:
Add tinymce to new textarea dynamically
http://blog.mirthlab.com/2008/11/13/dynamically-adding-and-removing-tinymce-instances-to-a-page/
Upvotes: 1