multiple tinymce textareas

前端 未结 5 1168
甜味超标
甜味超标 2021-02-07 14:26

I use tinymce for a webpage that dynamically generates at least 5 texts.
The configuration I use only works on the first textarea unfortunately.



        
5条回答
  •  無奈伤痛
    2021-02-07 15:02

    If you're using "exact" mode you'll need to specify the ids of the elements you wish to convert to editors.

    function initMCEexact(e){
      tinyMCE.init({
        mode : "exact",
        elements : e,
        ...
      });
    }
    // add textarea element with id="content" to document
    initMCEexact("content");
    // add textarea element with id="content2" to document
    initMCEexact("content2");
    // add textarea element with id="content3" to document
    initMCEexact("content3");
    

    Or, you can use the "textarea" mode, which indiscriminately applies the editor to all textareas.

    function initMCEall(){
      tinyMCE.init({
        mode : "textareas",
        ...
      });
    }
    // add all textarea elements to document
    initMCEall();
    

    Just remember that if you're creating textareas dynamically, you will need to call tinyMCE.init() after creating the elements, because they need to be existing for tinyMCE to be able to convert them.

    Here is the documentation on modes.

提交回复
热议问题