81777

Detecting tinyMCE textareas with JQUERY

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>

Answer1:

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.

Answer2:

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

Answer3:

Will work with if ( $(formElm + ' span.mceEditor').size() > 0) { ...do this};

Answer4:

I tried the following and it works, If I want to check on a textarea with the id 'tmce', then I appended '_parent' to it and tested it thus:

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

Answer5:

Can you add a sample of the textarea and span?

Recommend

  • Xamarin Forms Hide a Button on iOS and Show it on Android
  • Is it possible to prevent MSBuild printing colourized output
  • Cannot find class org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguratio
  • Test coverage for if statement with logical or (||) - with Java's short circuiting, what's
  • CKEditor separate the toolbar from the editor
  • Styling text for textarea Wicket
  • Python/Javascript: WYSIWYG html editor - Handle large documents fast and/or design theory
  • How to open html table in xls on click of a button
  • how to get username into sql trigger when multiple users signed on from asp membership
  • Web.config system.webserver errors
  • Force show.bind execution
  • Custom validator control occupying space even though display set to dynamic
  • Disable Enter in editText android
  • Django: Count of Group Elements
  • How can I send an e-mail from a vbs script
  • Sails.js/waterline: Executing waterline queries in toJSON function of a model?
  • Fetching methods from BroadcastReceiver to update UI
  • Can Jackson SerializationFeature be overridden per field or class?
  • How to redirect a user to a different server and include HTTP basic authentication credentials?
  • Symfony2: How to get request parameter
  • GridView Sorting works once only
  • retrieve vertices with no linked edge in arangodb
  • How to delete a row from a dynamic generate table using jquery?
  • WPF Applying a trigger on binding failure
  • log4net write single file for each call to log.info
  • Load html files in TinyMce
  • Getting error when using KSoap library to consume .NET web services
  • how does django model after text[] in postgresql [duplicate]
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • Change div Background jquery
  • Linking SubReports Without LinkChild/LinkMaster
  • apache spark aggregate function using min value
  • Easiest way to encapsulate a HTML5 webpage into an android app?
  • Busy indicator not showing up in wpf window [duplicate]
  • costura.fody for a dll that references another dll
  • Observable and ngFor in Angular 2
  • How to Embed XSL into XML
  • UserPrincipal.Current returns apppool on IIS
  • Conditional In-Line CSS for IE and Others?
  • java string with new operator and a literal