Clicky

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 http://www.rephunter.net/test-browser.php. 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:


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

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


asked 12/10/2011 06:21

jasimon9's gravatar image

jasimon9 ♦♦


3 Answers:
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.

1:
2:
3:
$(document).ready(function() {
   alert('body tinymce=' + typeof tinyMCE);
});
link

answered

nap0leon's gravatar image

nap0leon

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

answered 2011-12-11 at 06:32:52

jasimon9's gravatar image

jasimon9

While contributors solution was along the right lines, the real problem was the name that needed to be used.

link

answered 2011-12-13 at 13:16:44

jasimon9's gravatar image

jasimon9

Your answer
[hide preview]

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Tags:

×63
×1

Asked: 12/10/2011 06:21

Seen: 408 times

Last updated: 12/17/2011 05:20