I am trying to use the FCKEditor on a form that has two fields and running into a problem.
In the docs, there is a short statement that there can be multiple instances of an editor in the form, but I can't find an example.
In the form, I have two sections - a full description and a short description.
Then, in the javascript where I prepare the data for submission, I have this,
using jQuery to write into the hidden input fields.
The full description works.
However, with the short description, I get a javascript error.
Trying to comment things out to see where it occurs,
it seems to happen immediately when I call
var oEditor2 = FCKeditorAPI.GetInstance('fckShortDescription') ;
I am clearly doing something wrong.
Can someone help me understand what is going on and how to
correctly use two editor instance in the same page / form?
Thanks.
In the docs, there is a short statement that there can be multiple instances of an editor in the form, but I can't find an example.
In the form, I have two sections - a full description and a short description.
<p><label for="fck_desc">Description</label> <script type="text/javascript"> var oFCKeditor = new FCKeditor('fckDescription'); oFCKeditor.BasePath = "<%= request.getContextPath() %>/"; oFCKeditor.Width = 500; oFCKeditor.ToolbarSet = "Basic"; oFCKeditor.Create(); </script> <input type="hidden" name="fck_desc" value=""/> </p> <p><label for="fck_short_desc">Short Description</label> <script type="text/javascript"> var oFCKeditor2 = new FCKeditor('fckShortDescription'); oFCKeditor2.BasePath = "<%= request.getContextPath() %>/"; oFCKeditor2.Width = 500; oFCKeditor2.ToolbarSet = "Basic"; oFCKeditor2.Create(); </script> <input type="hidden" name="fck_short_desc" value=""/> </p>
Then, in the javascript where I prepare the data for submission, I have this,
using jQuery to write into the hidden input fields.
var oEditor = FCKeditorAPI.GetInstance('fckDescription') ; var fck = oEditor.GetXHTML(true); var fckDescription = ""; if (fck == null || fck.length === 0) { fckDescription = "<p> </p>"; } else { fckDescription = fck; } $('input[name=fck_desc]').val(fckDescription); var oEditor2 = FCKeditorAPI.GetInstance('fckShortDescription') ; //var fckShort = oEditor2.GetXHTML(true); //alert(fckShort); //var fckShortDescription = ""; //if (fckShort == null || fckShort.length === 0) { // fckShortDescription = "<p> </p>"; //} else { // fckShortDescription = fckShort; //} $('input[name=fck_short_desc]').val(fckShortDescription);
The full description works.
However, with the short description, I get a javascript error.
Trying to comment things out to see where it occurs,
it seems to happen immediately when I call
var oEditor2 = FCKeditorAPI.GetInstance('fckShortDescription') ;
I am clearly doing something wrong.
Can someone help me understand what is going on and how to
correctly use two editor instance in the same page / form?
Thanks.
Re: Two fields in a form
i have the same problem in my php code.
I try to use 2 fields on my form, but just one works.
i think is because you have two calls for the basepath.
my code:
like this, just fields FCKeditorIntro works and the value appears. for FCKeditorContenu nothing appears.
we have two calls for BasePath. how can i make just one call for both fields? if i try with one fields (FCKeditorContenu or FCKeditorIntro) it's ok.
Do you resolve your problem?
thx for your help