Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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>
Comment | File | Size | Author |
---|---|---|---|
fckeditor.patch | 611 bytes | pmetras |
Comments
Comment #1
pmetras CreditAttribution: pmetras commentedPerhaps 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');
Comment #2
wwalc CreditAttribution: wwalc commentedLooks 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.