I posted this over in the Open Discussions forum. I think I should have put it here. I hope someone here can help with my issue.
I'm running the demo code for FCK editor and I have the editor appearing in my web page.
However, I need the user to select from a list of documents and click a button. That button would build a link inside the editor window in a similar way it works in fck_link.js
I need to use the oEditor.FCK.CreateLink method to build that link but the FCK object is undefined. Here's a bit of my debug code:
var oEditor = FCKeditorAPI.GetInstance('FCKeditor1') ;
alert("oEditor is " + oEditor.Name + "\nStatus is " + oEditor.Status );
alert("oEditor.FCK is " + oEditor.FCK);
The first alert box shows me that the oEditor.Name is "FCKeditor1" and that the status is "2" which should be "FCK_STATUS_COMPLETE". This tells me that I do have a proper editor instance. Also, I can see and use the editor, including the "build a link" button from inside the editor.
The next alert box shows me that oEditor.FCK is undefined. This is odd since I know I have an editor created.
I see that the FCK object is defined in 3 places. It's in editor/_source/internals/fck.js and also in fck_gecko.js and fck_ie.js
Since I'm using Firefox I should be accessing the fck.js file. That made me wonder if I'm not set up correctly and there's some reason my code can't see the fck.js file.
However, It appears that my installation is set up correctly because if I use the "Link" button from the default tool bar then the link is properly created. So there must be something my setup that is allowing the internal FCKEditor Link code to call fck.js but not my own code.
Does anyone know why I can't access the oEditor.FCK object and what the solution should be? I've been searching the forums with no success.
Thank you
Greg
I'm running the demo code for FCK editor and I have the editor appearing in my web page.
However, I need the user to select from a list of documents and click a button. That button would build a link inside the editor window in a similar way it works in fck_link.js
I need to use the oEditor.FCK.CreateLink method to build that link but the FCK object is undefined. Here's a bit of my debug code:
var oEditor = FCKeditorAPI.GetInstance('FCKeditor1') ;
alert("oEditor is " + oEditor.Name + "\nStatus is " + oEditor.Status );
alert("oEditor.FCK is " + oEditor.FCK);
The first alert box shows me that the oEditor.Name is "FCKeditor1" and that the status is "2" which should be "FCK_STATUS_COMPLETE". This tells me that I do have a proper editor instance. Also, I can see and use the editor, including the "build a link" button from inside the editor.
The next alert box shows me that oEditor.FCK is undefined. This is odd since I know I have an editor created.
I see that the FCK object is defined in 3 places. It's in editor/_source/internals/fck.js and also in fck_gecko.js and fck_ie.js
Since I'm using Firefox I should be accessing the fck.js file. That made me wonder if I'm not set up correctly and there's some reason my code can't see the fck.js file.
However, It appears that my installation is set up correctly because if I use the "Link" button from the default tool bar then the link is properly created. So there must be something my setup that is allowing the internal FCKEditor Link code to call fck.js but not my own code.
Does anyone know why I can't access the oEditor.FCK object and what the solution should be? I've been searching the forums with no success.
Thank you
Greg
Re: Undefined FCK Editor Object
It looks like the problem is that we can't access the FCK object directly from outside of the FCKEditor iframe.
However, by using Firebug to examine the editor object I saw several methods not listed in the API page including the one I needed called EditorDocument.createElement.
http://docs.fckeditor.net/FCKeditor_2.x ... Script_API
My user had selected a document from a list. What they really selected was a URL to that document and the document name. The solution to creating a link to that document was this code:
// assume javascript exist for getting the url and name.
var oEditor = FCKeditorAPI.GetInstance('FCKeditor1') ;
var aLink = oEditor.EditorDocument.createElement('A');
aLink.href = url ;
aLink.innerHTML = name ;
oEditor.InsertElement(aLink);
So I was able to do what I needed via the oEditor methods rather than needing access to the oEditor.FCK.createElement
I hope that solution helps anyone else who is having a similar problem.
Re: Undefined FCK Editor Object