Add tinymce to new textarea dynamically

前端 未结 2 1075
耶瑟儿~
耶瑟儿~ 2020-12-11 04:20

How can i do this

function addTinyText(id, text){
//add textarea to DOM
$(\'\').append(text).appendTo(\'b         


        
2条回答
  •  一向
    一向 (楼主)
    2020-12-11 04:47

    I searched a very long time to find an answer to a similar problem.

    My content was not being posted even thou I could get the editor to appear.

    I got it working like this:

        jQuery('.wysiwyg').tinymce({
          // Location of TinyMCE script
          script_url : 'path/tinymce/tiny_mce.js',
    
          // General options
          theme : "advanced",
         .........
         .........
         ......... etc
    

    I used the standard jquery code to initiate all text areas with class name wysiwyg as tinymce objects.

    After ajax call completes and new textarea is loaded I run this function:

    jQuery(".wysiwyg").each(function(){ 
        tinyMCE.execCommand("mceAddControl",false, this.id);
    });
    

    Now my code is finally being posted correctly.

提交回复
热议问题