Detection of jquery.tinymce.js

We have a "browser test page" which is used to diagnose user problems. There are fields the user can fill out, plus quite a few detections as well. The data from that page can then be emailed into our tech support. The page is at The current page is no longer fully functional, for the following reason:

I have just converted the website from using dojo to jquery. Part of the test includes checking for tinymce support. We used to run the "regular" tinymce library, but have switched over to the jquery version. In the previous version, which used an older version of TinyMCE, support was tested by the following:

    if(typeof tinyMCE == 'undefined')

However, with the new instance of tinymce, it always comes up as undefined, even if there is a tinymce editor on the page. I have done some testing and it appears that tinyMCE is defined only after the form is submitted. For example, here is a snippet that shows how this works:

    <script type="text/javascript">
          alert('head tinymce=' + typeof tinyMCE);
          function Validate()
                alert('validate tinymce=' + typeof tinyMCE);
                if (tinyMCE)
                      alert('tinymce is defined');
    form onsubmit='Validate()'>
    <textarea class="tinymce"></textarea>
    <input type="submit" />
    <script type="text/javascript">
          alert('body tinymce=' + typeof tinyMCE);

No matter what I have done in the detection program, the only way to get a valid tinyMCE object seems to be to submit the page. That is, the 'body' alert does not work; the "validate" alert does.

One workaround is to put on the page instructions for the user to look at the page and see if there is an editor rather than just a textarea. However, with our users this would be less than ideal. We really want the email, and thus I need to have a way to detect tinyMCE.

I may be able to work this out by having an onsubmit function that detects tinymce, but I would also like something that can be displayed directly to the user on first display of the page.

Is there a simple solution? Something similar to the elegance of if(typeof tinyMCE == 'undefined')

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Try running the test in your document-ready section.  That way you give a chance for the code to load before you look for it.

$(document).ready(function() {
   alert('body tinymce=' + typeof tinyMCE);

Open in new window

jasimon9Author Commented:
The above is similar to what I had been trying. However, the approach will not work because of the way tinymce is defined in the plugin. Here is what does work:

if (typeof jQuery.fn.tinymce == 'undefined')

The essense here being the addition of the jQuery.fn to the object name.

Splitting points.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jasimon9Author Commented:
While contributors solution was along the right lines, the real problem was the name that needed to be used.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.