Hey guys, I've been trying to implement the template plugins in TinyMCE text editor following the documentation on their official website at TinyMCE Template Plugins Documentation. However, I'm having trouble with the JSON response when initializing it from TinyMCE like this:
Ajax Setup
$.ajaxSetup({
type: "POST",
url: "<?php echo base_url('admin_surat/json_get_template') ?>",
cache: false,
});
$("#surat_template_id").change(function() {
var value = $(this).val();
if (value > 0) {
$.ajax({
data: {
id: value
},
success: function(respond) {
var obj = respond.response.text;
}
})
}
});
Ajax Response
{
"title": "Surat Undangan",
"description": "Surat Undangan",
"url": "http:\/\/localhost\/ci-eoffice\/upload\/template-surat\/surat_undangan.html"
}
TinyMCE Init on HTML FILE
tinymce.init({
selector: "textarea", // change this value according to your HTML
plugins: "template",
menubar: "insert",
toolbar: "template",
templates: [obj]
});
Can anyone help me figure out how to pass the JSON response into the Template configuration during TinyMCE initialization? Thanks!