2

How to put retrieved text into Trumbowyg Textarea. I want to edit saved content using Trumbowyg. I have getting some text from database using Jquery Ajax. I am trying to put text using .html() and .text() function, but not working. I am trying to find solution from internet till now not get it.

HTML:

<textarea name="description" class="form-control" placeholder="Enter Description"></textarea>

Jquery:

$(".edit").click(function(){
        var id=$(this).attr("data-id");  
         $.ajax({
                type: "POST",
                url: "ajax.php",
                data: "formName=edit_sales_lead&id=" + id,
                success: function(res){
                    if(res!=""){
                            res=JSON.parse(res);
                            console.log(res[1]);  //test description
                            $("input[name='name']").val(res[0]);   
                            $("textarea[name='description']").html(res[1]);
                    }else{
                        console.log(res);
                    }
                }
            });
    });
sarbudeen
  • 171
  • 2
  • 10

1 Answers1

3
document.getElementById('editor').innerHTML = '<p>Your html content</p>';

or as suggested by @Taplar in comments:

$('#editor').trumbowyg('html', "<p>Your content here</p>");

would be another way of loading html content.