Hi there,
here's my code:
The save() function is called during an onClick event.
When the page is fully loaded there are no FCKeditor, but you may create them via javascript functions, that's why FCKeditorAPI is not initialized at once.
If I try to evoke the save() function when there are no editor loaded I get this error:
referred to the IF line.
But if I previously created an editor everything works fine, because FCKeditorAPI gets properly initialized!
That's quite strange... If you put a not-initialized variable or object in a IF condition it should simply return false and, in case, considering ELSE's code. Shouldn't it?
Thank you!
here's my code:
function save (id) { // some code if(FCKeditorAPI.GetInstance('descrizione_'+id)) { //do something } else { //do something else } // some code }
The save() function is called during an onClick event.
When the page is fully loaded there are no FCKeditor, but you may create them via javascript functions, that's why FCKeditorAPI is not initialized at once.
If I try to evoke the save() function when there are no editor loaded I get this error:
FCKeditorAPI is not defined
referred to the IF line.
But if I previously created an editor everything works fine, because FCKeditorAPI gets properly initialized!
That's quite strange... If you put a not-initialized variable or object in a IF condition it should simply return false and, in case, considering ELSE's code. Shouldn't it?
Thank you!
Re: "FCKeditorAPI is not defined" error in a IF statem
If an object is undefined, then attempting to unconditionally reference a method or attribute of the non-existent object will fail.
Re: "FCKeditorAPI is not defined" error in a IF statem
I had already tried to add "FCKeditorAPI &&" in the IF, but it hadn't worked.
I solved adding this line:
as the first istruction of my JavaScript code.