【问题标题】:Detecting tinyMCE textareas with JQUERY使用 JQUERY 检测 tinyMCE 文本区域
【发布时间】:2009-03-06 19:16:53
【问题描述】:

在我们的一些表单中,我们将 textareas 转换为 tinyMCE textareas。如何在 jquery 中判断给定的 textarea 是否已被转换?

我注意到 tinyMCE 会在初始化时将我的原始 textarea 的显示更改为 none,然后使用 mceEditor 类创建一个相邻的跨度,但下面的 jquery 语句似乎永远找不到它。

if ( $(formElm).siblings("span .mceEditor").size() > 0) { ...做这个};

if( $(formElm).parent().find("span .mceEditor").length > 0 ) {...做这个};

if( $(formElm).parent().children("span .mceEditor").size() > 0 ) {...做这个};

[编辑]

在tinymce 处理完textarea 后,有一个请求。来了

<td class="fields">
<textarea id="serviceDesc" class="form req blob" style="display: none;"> Warm and yummy in your tummy<br /></textarea>
<span id="serviceDesc_parent" class="mceEditor defaultSkin">
<table id="serviceDesc_tbl" class="mceLayout" cellspacing="0" cellpadding="0" style="width: 400px; height: 152px;">
<tbody>
<tr class="mceFirst">
<td class="mceIframeContainer mceFirst mceLast">
<iframe id="serviceDesc_ifr" frameborder="0" src="javascript:""" style="width: 100%; height: 129px;">
<html>
</html>
</iframe>
</td>
</tr>
<tr class="mceLast">
</tr>
</tbody>

【问题讨论】:

    标签: jquery tinymce


    【解决方案1】:

    快速提示:可能是您在 span 之后(在选择器中)放置了一个空格,这使得 jQuery 在 span 中查找具有名为“mceEditor”的类的元素。

    【讨论】:

      【解决方案2】:

      $('span.mceEditor+textarea:hidden') 会这样做吗?这假设“相邻”是指 mceEditor 跨度紧接在文本区域之前(ala FCKeditor)

      【讨论】:

        【解决方案3】:

        将与if ( $(formElm + ' span.mceEditor').size() &gt; 0) { ...do this};一起工作

        【讨论】:

          【解决方案4】:

          我尝试了以下方法,它有效, 如果我想检查 id 为 'tmce' 的 textarea,然后我将 '_parent' 附加到它并因此对其进行了测试:

          if( $("#tmce_parent").size() )
          {
          //code in case of a textarea with tinymce
          }
          

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2011-02-18
            • 2010-12-07
            • 1970-01-01
            • 1970-01-01
            相关资源
            最近更新 更多