tags:

views:

1066

answers:

3

On some of our forms we convert our textareas over to tinyMCE textareas. How can I tell in jquery if a given textarea has been converted?

I've notice that tinyMCE will change the display of my original textarea to none upon init and then creates an adjacent span with a class of mceEditor, but the follow jquery statements never seems to find it.

if ( $(formElm).siblings("span .mceEditor").size() > 0) { ...do this};

or

if( $(formElm).parent().find("span .mceEditor").length > 0 ) {...do this};

or

if( $(formElm).parent().children("span .mceEditor").size() > 0 ) {...do this};

[EDIT]

There was a request for what the textarea looks like after tinymce is done with it. Here goes

<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>

+1  A: 

Quick tip: It may be that you've put a space after the span (in the selector), which makes jQuery look for an element with a class named "mceEditor" in the span.

moff
It was the space. Good eye and thanks!
Scott
A: 

Can you add a sample of the textarea and span?

Shaun Humphries
A: 

does $('span.mceEditor+textarea:hidden') do it? this assumes by 'adjacent' you mean the mceEditor span immediately precedes the text area (ala FCKeditor)

Scott Evernden