When a fieldset is collapsible and the collapse.js code kicks in, the whizzywig suddenly loses height and all contents are dropped. This can be seen in action when you install the webforms module and create a new webform; the body text is inside a collapsible fieldset.
This is caused by the next-to-last line in collapse.js, which causes a reparenting of the whizzywig's iframe and the textarea it is associated with:
.append(fieldset.children(':not(legend):not(.action)')))
A workaround for this problem is to either disable whizzywig on fields that are in collapsible fieldsets (but that requires one to go through all pages to find the IDs, and in the case of webforms that means you have to disable all body text whizzywigs, which is not acceptible), or to disable collapsing on fieldsets that contain whizzywigs (but that's just as hard, if not harder because it requires overriding all forms in your theme)
I tried adding a line to the top of makeWhizzyWig():
if (whizzies.indexOf(idTa) != -1) return;
This gets rid of an error message in Firebug, but it doesn't solve the problem. It appears that because the script tag is inside the bit that gets reparented by collapse.js, the script tag's contents are re-evaluated.
The whizzywig module should probably use Drupal's behaviours system to get rid of these reevaluation problems, however this requires a large change in the whizzywig code itself because it uses document.write to write its contents, and that won't work after all the content is loaded...
Anyway, reevaluation doesn't seem to be the cause of the iframe content lossage.
Comments
Comment #1
barry_fisher commentedIf anybody is still struggling with this then I used this workaround to disable the #collapsible property on webforms.
This is a snippet from my theme's template.php. Obviously, you'll need to replace 'themename' with your actual theme name or template engine ('phptemplate', for example.)
Don't forget to flush the theme registry cache after adding this, so your theme function gets registered!
For more information on how and why this works- please check out http://www.lullabot.com/articles/modifying-forms-drupal-5-and-6. Thanks to Addi Berry for this!
--
Barry Fisher
Real Life Design
Comment #2
Joel MMCC commentedA simple workaround for now is to go to “Site configuration | Whizzywig | Visibility” and tell Whizzywig to not show up on Content type “webform” (and any others you might have installed in which Body and/or Teaser fields are inside collapsible framesets). You lose Whizzywig on those content types, but at least you can manually edit their Bodies that way.
Comment #3
drupalnesia commented6.x-2.0-alpha2: Bug fix: show whizzywig on block
Use the same method on 6.x-2.0-alpha2, then I can add a Setting to disable collapsible fieldset when a form contains Whizzywig, what do you think?
If ok then I will add this Setting in 6.x-2.0-alpha3.
Comment #4
drupalnesia commentedToday I just install Webform (cause I usually depend on CKK). After learning Webform a while I see Webform has option to set a field set to "Collapsible = False". So, this is a temporary workaround :)
I agree with Peter Bex that Whizzywig must meet drupal.js, I have submit this issue to whizzywig.js, hope there is a patch for this js.
To avoid any issue with other fieldsets then I will add option for:
- User able to determine which fieldset ids should be un-collapsible, this values separated by comma
This will apply to next version of Whizzywig ASAP.
Comment #5
drupalnesia commented6.x-2.0-alpha3:
---------------
Bug fix: toolbar_custom get 'whizzywig_toolbar_medium' instead 'whizzywig_toolbar_custom'
Bug fix: setting to determina which collapsible field set to un-collapsed
Bug fix: disable editor on Whizzywig Settings-page
Bug fix: better compability to PHP 5.3 (not tested)
Bug fix: set toolbar textfield to texarea to accomodate > 128 chars
Comment #6
maulwuff commentedthis one seems related #844736: Can't enter text with Vertical Tabs
Comment #7
drupalnesia commented#6 Please discuss only here: http://drupal.org/node/844736
don't make unlimited iteration :)
Comment #8
drupalnesia commented