I’m trying to load content from records in my database, the database does indeed return the correct values; the problem is populating TinyMce with said values.
The HTML:
<textarea cols="20" class="tiny modal-body-content">
</textarea>
The Ajax (jQuery)
$.ajax({
type: "POST",
url: '/WebServices/masterData.asmx/ShowBio',
data: t,
cache: false,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
error: OnError,
timeout: 15000
});
function OnSuccess(data, status) {
if (data.d != "false") {
tinymce.init({
selector: "tiny",
setup: function (editor) {
editor.on('init', function () {
editor.setContent(data.d);
})
}
})
}
I also tried populating the HTML into the ID TinyMce generates using:
$(".mce-edit-area").html(data.d);
Although this does put the HTML into the TinyMce editor, it’s not editable, and quite clearly a massive bodge.
Does anybody know what I’m doing wrong here?
2
Answers
This worked:
this will add the content (tag/element/text or whatever .. ) exactly in the current mouse position :
while this will inject directly the content on the TinyMce editor (wiping of the previous content)
Here is a quick example with AJax :