Javascript 我正在使用tinymce,是否可以只申请一个textarea

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5192496/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 16:05:48  来源:igfitidea点击:

I am using tinymce, Is it possible to apply for only one textarea

javascripttinymcetextarea

提问by Navruk

I am using tinymce, I have multiple text areas on my page. Is it possible to apply for only one textarea,

我正在使用 tinymce,我的页面上有多个文本区域。是否可以只申请一个textarea,

1 text area is for description validation is like below

1 文本区域用于描述验证,如下所示

var text = tinyMCE.get('txtdesc').getContent();

But i have more 3 more text areas in my page so tineMCE should not apply for all these text areas

但是我的页面中还有 3 个更多的文本区域,因此 tineMCE 不应应用于所有这些文本区域

How can i apply only for one text area

我如何只申请一个文本区域

// this is my tinyMCE code 
    tinyMCE.init({
        mode : "textareas",
        theme : "advanced"
    });

// /tinyMCE

回答by chinna

For the textareaassign a class=""to textarea property, this will support for you

对于textarea分配class=""给 textarea 属性,这将为您提供支持

<script type="text/javascript">
    tinyMCE.init({
        //mode : "textareas",
        mode : "specific_textareas",
        editor_selector : "myTextEditor",
        theme : "simple"
    });
</script>

<textarea id="txtdesc" name="txtdesc" class="myTextEditor" rows="6" cols="96" ></textarea>

回答by Dunhamzzz

In the TinyMCE 3.x config you can put class selectors or deselectors to specifically enable or disable TinyMCE on textareas with certain classes, just put the class=""attribute on your textarea.

在 TinyMCE 3.x 配置中,您可以放置​​类选择器或取消选择器以在具有某些类的文本区域上专门启用或禁用 TinyMCE,只需将class=""属性放在您的文本区域上。

editor_deselector : "mceNoEditor" // class="mceNoEditor" will not have tinyMCE
editor_selector : "mceEditor", // class="mceEditor" will.

Source.

来源



As of TinyMCE 4.0.x

从 TinyMCE 4.0.x 开始

selector: "textarea", // Select all textarea
selector: "textarea.editme", // Select all textarea with the class editme
selector : "textarea:not(.mceNoEditor)", // Select all textarea exluding the mceNoEditor class

Source.

来源

回答by KEOKI

In TinyMCE 4.x there is no deselector so you can use normal css to determine which textareas are selected and which are not.

在 TinyMCE 4.x 中没有取消选择器,因此您可以使用普通的 css 来确定哪些 textareas 被选中,哪些没有。

<script type="text/javascript">
  tinymce.init({
        selector: "textarea:not(.textarea-no-styles)",
 });
</script>

回答by user2395940

In TinyMCE 4.x, you can use editor_selector option , but before that make sure you must updated mode to 'specific_textareas'

在 TinyMCE 4.x 中,您可以使用 editor_selector option ,但在此之前请确保您必须将模式更新为“specific_textareas”

    <script type="text/javascript">
  tinymce.init({
    mode : "specific_textareas",
    editor_selector : "mceEditor",
    });
</script>

Also add css class same as editor_selector value in your textarea, as per above example it should look like this:

还要在你的 textarea 中添加与 editor_selector 值相同的 css 类,按照上面的例子,它应该是这样的:

<textarea id='textarea1' class='mceEditor'>first text area</textarea>

now, editor will be added in those textarea that have a class named 'mceEditor'.

现在,将在具有名为“mceEditor”的类的那些文本区域中添加编辑器。

回答by renaissance-dating.com

Here's what worked for me on version 4.6.4, and it's simpler :

这是在 4.6.4 版本上对我有用的方法,它更简单:

I've just appended #my_text_area_id to my selector as follows

我刚刚将 #my_text_area_id 添加到我的选择器中,如下所示

selector: 'textarea#elm1'
<textarea id="elm1" ...>...</textarea>

hope it helps

希望能帮助到你

回答by sandeep kumar

You can do this by using a selector.

您可以通过使用selector.

selector: "#text_area_id", // Select with textarea id