JS error if editor loaded within a div with display:none

Looking for help? Ready to help? That's the place to go.

JS error if editor loaded within a div with display:none

Postby malis » Mon Feb 25, 2008 4:39 pm

Hi,

while updating to FCKEd 2.5.1, I've noticed a problem that did not seem to exist in the past.
I use two editors on one page, the first one is always displayed, the other one is hidden in a div with display:none set (it's 'activated' - its display is set to block - on basis of some further user's actions).
The problem is that when this (hidden) editor is supposed to be loaded, it throws an error (800a025e). This behavior has been registered in IE7 but I have a suspicion that something weird is happening in Gecko, too (it does not report any error but the 'loading' cursor seems to appear on the screen way too long). It's really strange because with an exception of this error alert, everything seems to be functioning the way it should. In addition - I used the same code with a previous version - 2.2 - and none of these ever happened.
If I let the editor load without setting display:none and hide the editor only after it is loaded, no problem occurs whatsoever. StartupFocus is set to false, I don't know if any other setting parameters could affect this behavior.

2.5 has is a great step forward (I no longer have to post process various non-xhtml features) but this behavior surprised me a little and I'm unable to do anything about it.

Does anybody know what I might be doing wrong? (I use the bundled php classes to call the editor although I'm almost positive that it is not the problem).

Thanks a lot for assistence.

Malis
malis
 
Posts: 6
Joined: Mon Feb 25, 2008 4:06 pm

Re: JS error if editor loaded within a div with display:none

Postby malis » Mon Feb 25, 2008 6:43 pm

I've solved it for myself by using FCKeditor_OnComplete function. Therefore let this remain just a piece of information for others/authors that this may occur. I don't think that it is the intended behavior of the editor anyway, so it may inspire you (authors) to have a look at it. Fortunately, it's no longer a problem for me.
malis
 
Posts: 6
Joined: Mon Feb 25, 2008 4:06 pm

Re: JS error if editor loaded within a div with display:none

Postby alfonsoml » Mon Feb 25, 2008 7:20 pm

Could you please file a bug with your original page so we can reproduce the problem and understand if it's something that must be fixed?
alfonsoml
 
Posts: 2662
Joined: Sun Dec 31, 2006 9:50 am
Location: Spain

Re: JS error if editor loaded within a div with display:none

Postby igfarm » Mon Feb 25, 2008 7:58 pm

malis wrote:I've solved it for myself by using FCKeditor_OnComplete function. Therefore let this remain just a piece of information for others/authors that this may occur. I don't think that it is the intended behavior of the editor anyway, so it may inspire you (authors) to have a look at it. Fortunately, it's no longer a problem for me.


Having the same issue... did you just create an empty FCKeditor_OnComplete function ?
igfarm
 
Posts: 1
Joined: Mon Feb 25, 2008 7:56 pm

Re: JS error if editor loaded within a div with display:none

Postby malis » Mon Feb 25, 2008 8:05 pm

Here we go:

System: XP Home Edition (Czech), MSIE7

I tried to copy it over the samples included in the public distribution, trim it as much as possible and it turned out that it probably really wasn't my mistake - the bug still exists. Here are the two lines that generate the two editors (as copied from the php output; after deleting all the config stuff - it did not solve the problem either)

Code: Select all
<div><input type="hidden" id="ArticleText0" name="ArticleText0" value="bla" style="display:none" /><input type="hidden" id="ArticleText0___Config" value="" style="display:none" /><iframe id="ArticleText0___Frame" src="../../editor/fckeditor.html?InstanceName=ArticleText0&amp;Toolbar=Default" width="100%" height="400" frameborder="0" scrolling="no"></iframe></div>
[color=#008000]<div style="display:none">[/color]<input type="hidden" id="ArticleText1" name="ArticleText1" value="" style="display:none" /><input type="hidden" id="ArticleText1___Config" value="" style="display:none" /><iframe id="ArticleText1___Frame" src="../..//editor/fckeditor.html?InstanceName=ArticleText1&amp;Toolbar=Default" width="100%" height="400" frameborder="0" scrolling="no"></iframe></div>


That's interesting that if input "ArticleText1" does not have the value empty, the error does not occur (I hide the latter editor right in case its value is empty - in practice it works as follows: the first editor can be either the entire article or just a kind of an annotation and in such a case the other editor is used for the rest of the article).

Let me add a solution for those who might find it useful right now:

<div style="display:none"> is, in practice, actually: <div class="HideFCKEditor" id="HiddenFCKArticleText1">

Code: Select all
function FCKeditor_OnComplete( editorInstance )
{
   if (document.getElementById ( 'HiddenFCK' + editorInstance.Name )) {
      HideFCKEditorByInstanceName (editorInstance.Name);
   }
}

function HideFCKEditorByInstanceName ( editorInstanceName ) {
   if (document.getElementById ( 'HiddenFCK' + editorInstanceName ).className == "HideFCKEditor" ) {
      document.getElementById ( 'HiddenFCK' + editorInstanceName ).className = "nodisplay";
      }
}


Of course even this is a little simplified but I hope you can see the way the workaround works.


JFYI: The complete page (the rest of the stuff comes from the original sample):

Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
* Copyright (C) 2003-2007 Frederico Caldeira Knabben
*
* == BEGIN LICENSE ==
*
* Licensed under the terms of any of the following licenses at your
* choice:
*
*  - GNU General Public License Version 2 or later (the "GPL")
*    http://www.gnu.org/licenses/gpl.html
*
*  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
*    http://www.gnu.org/licenses/lgpl.html
*
*  - Mozilla Public License Version 1.1 or later (the "MPL")
*    http://www.mozilla.org/MPL/MPL-1.1.html
*
* == END LICENSE ==
*
* Sample page.
-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
   <title>FCKeditor - Sample</title>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
   <meta name="robots" content="noindex, nofollow" />
   <link href="../sample.css" rel="stylesheet" type="text/css" />
   <script type="text/javascript" src="../../fckeditor.js"></script>
</head>
<body>
   <h1>
      FCKeditor - JavaScript - Sample Bug
   </h1>
   <div>
      This sample displays a normal HTML form with an FCKeditor with full features enabled.
   </div>
   <hr />
   <form action="_someaction.php" method="post" target="_blank">
   <div>
         <div><input type="hidden" id="ArticleText0" name="ArticleText0" value="bla" style="display:none" /><input type="hidden" id="ArticleText0___Config" value="" style="display:none" /><iframe id="ArticleText0___Frame" src="../../editor/fckeditor.html?InstanceName=ArticleText0&amp;Toolbar=Default" width="100%" height="400" frameborder="0" scrolling="no"></iframe></div>
         <div style="display:none"><input type="hidden" id="ArticleText1" name="ArticleText1" value="" style="display:none" /><input type="hidden" id="ArticleText1___Config" value="" style="display:none" /><iframe id="ArticleText1___Frame" src="../../editor/fckeditor.html?InstanceName=ArticleText1&amp;Toolbar=Default" width="100%" height="400" frameborder="0" scrolling="no"></iframe></div>
      <br />
      <input type="submit" value="Submit" />
   </form>
</body>
</html>
Last edited by malis on Mon Feb 25, 2008 8:20 pm, edited 1 time in total.
malis
 
Posts: 6
Joined: Mon Feb 25, 2008 4:06 pm

Re: JS error if editor loaded within a div with display:none

Postby malis » Mon Feb 25, 2008 8:15 pm

igfarm wrote:
malis wrote:I've solved it for myself by using FCKeditor_OnComplete function. Therefore let this remain just a piece of information for others/authors that this may occur. I don't think that it is the intended behavior of the editor anyway, so it may inspire you (authors) to have a look at it. Fortunately, it's no longer a problem for me.


Having the same issue... did you just create an empty FCKeditor_OnComplete function ?


You were faster them me typing the previous reply. Anyway, the solution is inlcuded there. It seems to be working just fine although it may not be absolutely "elegant" ;)
malis
 
Posts: 6
Joined: Mon Feb 25, 2008 4:06 pm

Re: JS error if editor loaded within a div with display:none

Postby malis » Mon Feb 25, 2008 8:18 pm

Of course, I'm talking s**t - the div actually looks like this <div class="HideFCKEditor" id="HiddenFCKArticleText1">

I fixed it in the original post so as not to confuse anyone.
malis
 
Posts: 6
Joined: Mon Feb 25, 2008 4:06 pm

Re: JS error if editor loaded within a div with display:none

Postby alfonsoml » Mon Feb 25, 2008 11:09 pm

I've tested that page with the current code (today the 2.6beta was released) and it seems to work fine in IE7
alfonsoml
 
Posts: 2662
Joined: Sun Dec 31, 2006 9:50 am
Location: Spain

Re: JS error if editor loaded within a div with display:none

Postby cdm9002 » Wed Feb 27, 2008 7:24 pm

I added the FCKeditor_OnComplete() into my page, but in IE6 I still get the error, presumably because it hasn't reached that stage to call the oncomplete function yet. Did you try IE6 too?

I had to change my "display:none" to "visibility:hidden" (which doesn't get the error), then in code set it back to "display:none" once the page has loaded.
cdm9002
 
Posts: 1
Joined: Wed Feb 27, 2008 7:21 pm

Re: JS error if editor loaded within a div with display:none

Postby rodes74 » Fri Apr 04, 2008 6:27 pm

Does anyone have a solution for this error?? In what file should i put the function FCKeditor_OnComplete function????
rodes74
 
Posts: 4
Joined: Tue Apr 01, 2008 10:14 pm

Next

Return to Support

Who is online

Users browsing this forum: Google [Bot], Yahoo [Bot] and 4 guests