When I have TinyMCE enabled, some pages won't load. The link "enable rich text" appears in the top left of the page, the rest of the page is white, and the loading icon just spins.

It seems to be just these pages affected (the first 2 obviously worked the first time):
/admin/settings/tinymce/edit/(profilename)
/admin/settings/tinymce/add
/admin/user/settings

Most other non-core modules are turned off.
I've done both patches here http://drupal.org/node/244066.
I'm using:
Drupal 6.2
Mac OSX
Firefox 2

I did get this warning in IE6/Win:
Invalid argument supplied for foreach() in .../includes/form.inc on line 1181

Comments

raspberryman’s picture

I was able to reproduce this with a webform node's edit page.

greenskunk’s picture

I have the same problem. When you attempt to create content or edit content the templated page appears for a second and then the javascript error occurs and the page goes blank and a link with the words 'Enable rich-text' appears.

This is directly related to applying the patches mentioned by Zelavi.

Firebug says:

$ is not defined
http://example.tld/drupal/misc/collapse.js?F
Line 55

I am on Drupal 6.2
TinyMCE Module 6.x-1.1-dev with patches from http://drupal.org/node/244066

raspberryman’s picture

Title: Some pages won't load w/TinyMCE enabled MacX FF2 » Some pages won't load w/TinyMCE enabled FF2

Reproduced with FF2 on Windows XP.

hansl’s picture

I can confirm this, and after some investigation I've found what appears to be the reason. The patch to enable the "disable rich text"/"enable rich text" links adds a JavaScript snippet after the textarea in question, and the last "document.write()" somehow causes the browser to behave as described, when tiny_mce is activated for the "log message" textarea under "Revision information" (and possibly other areas where it shouldn't be enabled).

I don't have time to investigate this in detail, but it seems the supported way of controlling which textareas are supposed to be affected is the one described in the next to last section of the README.TXT included with the tinymce module.

I copied the innards of the theme_tinymce_theme() function into an equivalent function in the template.php file in my active theme, in this case called phptemplate_tinymce_theme(), and already containing some other code.

With this in place, tiny_mce appears only where it's supposed to, and the patch for the "disable rich text"/"enable rich text" link works.

Hope this helps,

Hans

greenskunk’s picture

I still can't get this to work with the patch applied.

Firebug says:

$ is not defined
http://web-site.tld/drupal/misc/collapse.js?F
Line 55
collapse() collapse.js (line 55)
e([legend.collapse-processed, legend.collapse-processed, legend.collapse-processed, 8 more...], function(), undefined)jquery.js (line 13)
e(function(), undefined)jquery.js (line 13)
collapse(Document drupal)collapse.js (line 54)
(no name)()drupal.js (line 42)
e(Object, function(), undefined)jquery.js (line 13)
attachBehaviors(Document drupal)drupal.js (line 41)
(no name)()drupal.js (line 276)
e()jquery.js (line 13)
e()jquery.js (line 13)
e([function(), function(), function(), 2 more...], function(), undefined)jquery.js (line 13)
e()jquery.js (line 13)
[Break on this error] var fieldset = $(this.parentNode);
hansl’s picture

GreenSkunk, try finding the definition for $wysiwyg_link in tinymce.module, and go to the next to last line of that block - it starts with
document.write("<div><a href=\"javascript:mceToggle

Place a comment mark (double slash: "//") in front of that, and don't change anything else. Does the page load now? If so, look at the source and try to find out if there are more than one occurrence of that code - you can search for "mceToggle" and look for calls to that function.

If you have more than one occurrence of this code, you have encountered the same problem as I did.

You'll have to make sure there are no tiny_mce textareas on the page except the legitimate ones, which is probably just the body text itself.

Oh, and don't forget to remove the comment mark afterwards.

greenskunk’s picture

Thanks for the reply Hansl.

There are no other TinyMCE areas on the page. After commenting out the mceToggle, the page does load but the textarea is not converted to a TinyMCE editor.

I wonder if my problem is related to a javascript library collision. I'm going to comment out some other javascript and see what happens.

dkalbfle’s picture

Priority: Normal » Critical

I was having this problem with Drupal 6.2 with tinymce-6.x-1.1-dev

There is some code in tinymce.module, in the theme_tinymce_theme() function, that is causing this problem. The switch statement inspects $textarea_name to determine whether the given textarea should get the tinyMCE editor. The problem is that $textarea_name contains textarea names that contain hyphens, but it is being compared against values with underscores.

i.e. 'access-pages' is being compared with 'access_pages', the comparison fails, and the page goes into some kind of loop and never returns HTML to my browser (that's what happens on my machine, anyway)

To work around this problem, change the switch statement from:

switch ($textarea_name) {

to

switch (str_replace('-','_',$textarea_name)) {

I'll leave it to the module developer to come up with a more graceful patch :)

Dave.

armyofda12mnkeys’s picture

Version: 6.x-1.1-dev » 5.x-1.9
Component: Miscellaneous » Code

hmmm had this same issue with 5.x-1.9
tried the above workaround and it didnt work. any ideas?
i started noticing it in the administration Edit users pages, but then started seeing in on other pages i thought werent affected like node/1/edit.
very funky cause i didnt change anything and i thought it was working on node pages (i did have it working).
using tinymce js version 2.1.3 and i just see the enable rich text in top left corner and nothing on the page and page keeps trying to load.
Firebug reports this error:
$ is not defined
http://drupaltest/misc/textarea.js
Line 4 $('textarea.resizable:not(.processed)').each(function() {

armyofda12mnkeys’s picture

this thread i think put a solution that works:
http://drupal.org/node/235972

here is their patch:

<     document.write("<div><a href=\"javascript:mceToggle('edit-$textarea_name', 'wysiwyg4$textarea_name');\" id=\"wysiwyg4$textarea_name\">$link_text</a></div>");
---
>     $('#edit-$textarea_name').after("<div><a href=\"javascript:mceToggle('edit-$textarea_name', 'wysiwyg4$textarea_name');\" id=\"wysiwyg4$textarea_name\">$link_text</a></div>");
chirale’s picture

Status: Active » Closed (duplicate)