多个tinymce文本区域 [英] multiple tinymce textareas

查看:270
本文介绍了多个tinymce文本区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将tinymce用于动态生成至少5个文本的网页.
不幸的是,我使用的配置仅适用于第一个textarea.

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

tinyMCE.init({
    height : "300",
    mode : "exact",
    elements : "content",
    theme : "simple",
    editor_selector : "mceEditor",
    ...

<textarea class="mceEditor" name="content" rows="15" cols="40">content</textarea>

全部 textarea中启用tinymce编辑的配置是什么.

What's the configuration to enable tinymce editing in all textarea's.

推荐答案

如果您使用的是精确"模式,则需要指定要转换为编辑器的元素的ID.

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();

请记住,如果要动态创建文本区域,则需要在创建元素之后调用tinyMCE.init() ,因为它们必须存在,以便tinyMCE能够转换它们

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.

此处是有关模式的文档.

这篇关于多个tinymce文本区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆