Search code examples
jqueryjsonjquery-jtable

jtable tinymce passing data while updating a record?


I'm using Jquery jtable to update data in pages table, and using tinymce editor to update html content of the page record.

I do not want to retrieve text data from database because the data will be huge, so I'm retrieving it on formCreated event using getJson.

everything is ok except I can not assign the html retrieved from the database to the tinymce textarea.

Here is the code:

    formCreated: function (event, pagedata) {

                var pid = pagedata.record['pId'];
                var pText = "";
                $.getJSON('/JsonService/Pages-List/?pid=' + pid, function (data) {
                    pText = JSON.stringify(data.pText, null, 2);
                    document.getElementById("Edit-pText").innerHTML = data.pText;
                    alert(document.getElementById("Edit-pText").innerHTML);
                    document.getElementById("Edit-pText").innerHTML = JSON.stringify(pText);
                });

                tinymce.init({.......});

Solution

  • I solved it by putting the the tinymce.init({ inside $.getJSON block:

        formCreated: function (event, pagedata) {
                    var pid = pagedata.record['pId'];
    
                    $.getJSON('/cms/JsonService/Pages-List/?pid=' + pid, function (data) {
                        document.getElementById("Edit-pText").innerHTML = data.pText;
    
                        tinymce.init({........});
    
                    });