I've looked over the JavaScript API, but can't seem to get it to work.
I made a custom ComboBox plugin for something I'm doing. I want to use the AddItem method to add the items dynamically when the editor instance is instantiated.
I've tried the following:
1. Setting an editor object value like
oFCKeditor.myCustomValue = '"some string";
and then creating the editor.
But then I can't access myCustomValue inside the plugin. I tried referring to the editor instance itself with "var oEditor = window.parent.InnerDialogLoaded().FCK;", but that didn't work. I also tried "var oEditor = FCKeditorAPI.GetInstance('InstanceName') ;". In both cases oEditor does not get set to any object.
2. I've also tried setting a hidden field on the same page as the editor and then getting the values with getElementById, like in
var myCustomValue = document.getDocumentById('myCustomValue').value;
but that always ends up being a null value, even though the hidden field with that id is in the source for that page. I also tried this variation:
var myCustomValue = window.parent.getElementById('myCustomValue').value;
but that also didn't work. No value found.
So... any suggestions? This is the last missing piece to getting my plugin to work. How do I pass information from outside the plugin to the plugin at the time the editor is instantiated?
Thanks for any suggestions!
doug
I made a custom ComboBox plugin for something I'm doing. I want to use the AddItem method to add the items dynamically when the editor instance is instantiated.
I've tried the following:
1. Setting an editor object value like
oFCKeditor.myCustomValue = '"some string";
and then creating the editor.
But then I can't access myCustomValue inside the plugin. I tried referring to the editor instance itself with "var oEditor = window.parent.InnerDialogLoaded().FCK;", but that didn't work. I also tried "var oEditor = FCKeditorAPI.GetInstance('InstanceName') ;". In both cases oEditor does not get set to any object.
2. I've also tried setting a hidden field on the same page as the editor and then getting the values with getElementById, like in
var myCustomValue = document.getDocumentById('myCustomValue').value;
but that always ends up being a null value, even though the hidden field with that id is in the source for that page. I also tried this variation:
var myCustomValue = window.parent.getElementById('myCustomValue').value;
but that also didn't work. No value found.
So... any suggestions? This is the last missing piece to getting my plugin to work. How do I pass information from outside the plugin to the plugin at the time the editor is instantiated?
Thanks for any suggestions!
doug
Re: How can I pass values to a plugin when the editor starts up?
That did not work. Inside the plugin the var oEditor assignment caused an error. But just leaving out that line like this:
did work, and now the plugin works.
I don't know why the assignment of the editor instance doesn't work, but as long as FCK was available and now I know I can pass data via the FCK.Config associative array, all is well.
Thanks,
doug
Re: How can I pass values to a plugin when the editor starts up?
Yes, a call to window.parent.InnerDialogLoaded(); must be done only inside a dialog, not in the plugin code because that code already runs in the same context as the main FCKeditor code.
Also, the InnerDialogLoaded() must be done only ONCE, and it must be called while the dialog is loading the <head> in order to properly set the styles. It's absolutely wrong to suggest that call as a general way to access the editor, it must be called only once, and store the return value.