It can happen that a template includes conditionnaly textareas in the page. FCKeditor replaces all these textareas by its JavaScript magic and put some code in the print($closure) to enable the display of the editors. If some JavaScript oFCK_N objects are not defined in the page, JavaScript execution will stop and the other editors will fail to display.

For instance, in the following code, if oFCK_2 has not been included in the resulting HTML, oFCK_4 and oFCK_5 will never display:

<script type="text/javascript">if (Drupal.jsEnabled) {$(document).ready(function() {oFCK_2.ReplaceTextarea();});}</script>
<script type="text/javascript">if (Drupal.jsEnabled) {$(document).ready(function() {oFCK_4.ReplaceTextarea();});}</script>
<script type="text/javascript">if (Drupal.jsEnabled) {$(document).ready(function() {oFCK_5.ReplaceTextarea();});}</script>

To solve this problem, we just need to check that the oFCK_N objects exist in the page, using some code like:

<script type="text/javascript">if (Drupal.jsEnabled && oFCK_2) {$(document).ready(function() {oFCK_2.ReplaceTextarea();});}</script>
CommentFileSizeAuthor
fckeditor.patch611 bytespmetras
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pmetras’s picture

Perhaps a better and more portable way for all browsers (including IE5) to write it would be to use a try/catch block:

drupal_add_js('if (Drupal.jsEnabled) { try { '. $js_id .'; $(document).ready(function() {'. $js_id .'.ReplaceTextarea();}); } catch(_) {} }', 'inline', 'footer');

wwalc’s picture

Status: Needs review » Closed (duplicate)

Looks like na interesting idea. Anyway, the new way of loading FCKeditor has been introduced in #261483: Having the FCK editor load upon page completion (FCK failes in some occasions within fieldsets) and let's give it a try. It should solve the problem described in this ticket.
Thanks for your time and let us know if you find anything wrong in the latest dev release.