且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

具有tinyMCE的文本区域的setContent

更新时间:2023-12-03 21:30:40

我有解决方案(感谢Thariama给了我一些元素)

I have the solution (thans to Thariama who gives me some elements)

要使用tinyMCE设置文本区域的内容,我们需要在初始化tinyMCE之前先填充文本区域.另外,响应如下:

To set the content of an textarea using tinyMCE, we heve to fill in the textarea before init the tinyMCE. Also, the response is as follows:

  1. 创建文本区域:

  1. Create the textarea:

<textarea style="width: 95%;" name="Title"  id="title"></textarea>

  • 设置文本区域的内容:

  • Set the content of the textarea:

    $('#title').html(selected_article_title);
    

  • 初始化tinyMCE:

  • Init the tinyMCE:

    tinyMCE.init({
    // General options
    mode : "specific_textareas",
    theme : "advanced",
    width: "100%",
    plugins : "pagebreak,paste,fullscreen,visualchars",
    
    // Theme options
    theme_advanced_buttons1 : "code,|,bold,italic,underline,|,sub,sup,|,charmap,|,fullscreen,|,bullist,numlist,|,pasteword",
    theme_advanced_buttons2 :"",
    theme_advanced_buttons3 :"",
    theme_advanced_buttons4 :"",
    theme_advanced_toolbar_location : "top",
    theme_advanced_toolbar_align : "left",
    theme_advanced_statusbar_location : "bottom",
    valid_elements : "i,sub,sup",
    invalid_elements : "p, script",
    editor_deselector : "mceOthers"
    });
    

  • 就完成了!享受.