Set textarea value with javascript after TinyMCE initializing

前端 未结 6 668
终归单人心
终归单人心 2021-02-01 14:59

I hava an textarea and I am using tinyMCE on that textarea.

What I am doing actually is that when the page is opened, I am populating the textarea with some text, and af

6条回答
  •  醉话见心
    2021-02-01 15:53

    I had the same problem solved by making sure the setContent was done after the document is ready, so first;

    script(type="text/javascript").
      tinymce.init({
        selector: '#title',
        height: 350,
        menubar: false
      });
    

    then

    script(type='text/javascript').
      $(document).ready(function(){
        tinymce.get('title').setContent('someText is html');
      })
    

    Above is code for pug, but the key is -as mentioned- to load it on document ready.

提交回复
热议问题