Search code examples
javascriptjqueryfckeditor

how to delete content from textarea in FCKeditor


I'm trying to delete the content or value from a textarea box created with FCKeditor. I have tried all the standard ways with javaScript and jquery and it's still there, so I may be missing something.

This is a dev environment I have no control over, we are using IE8 and FCKeditor 2.6.6

Here is the code creating the TextArea (I have no control over this)

    <script type="text/javascript"> 
//<![CDATA[
   window.onload = function()
   {
      var oFCKeditor = new FCKeditor( 'Absence Date' ) ;
      oFCKeditor.BasePath = "/fckeditor/" ;
      oFCKeditor.ToolbarSet = "Composer" ;
      oFCKeditor.ReplaceTextarea() ;
      var oFCKeditor = new FCKeditor( 'Hours Counted Against' ) ;
      oFCKeditor.BasePath = "/fckeditor/" ;
      oFCKeditor.ToolbarSet = "Composer" ;
      oFCKeditor.ReplaceTextarea() ;
      var oFCKeditor = new FCKeditor( 'test' ) ;
      oFCKeditor.BasePath = "/fckeditor/" ;
      oFCKeditor.ToolbarSet = "Composer" ;
      oFCKeditor.ReplaceTextarea() ;
   };
   function FCKeditor_OnComplete( editorInstance )
   {
      if (editorInstance.Name == "Absence Date")
         {
            editorInstance.EditorWindow.parent.FCKToolbarItems.GetItem( 'About' )._UIButton.MainElement.title = 'Absence Date';
            FCKeditorAPI.GetInstance('Absence Date').Commands.GetCommand('About').Execute = function() { return false; };
         };
      if (editorInstance.Name == "Hours Counted Against")
         {
            editorInstance.EditorWindow.parent.FCKToolbarItems.GetItem( 'About' )._UIButton.MainElement.title = 'Hours Counted Against';
            FCKeditorAPI.GetInstance('Hours Counted Against').Commands.GetCommand('About').Execute = function() { return false; };
         };
      if (editorInstance.Name == "test")
         {
            editorInstance.EditorWindow.parent.FCKToolbarItems.GetItem( 'About' )._UIButton.MainElement.title = 'test';
            FCKeditorAPI.GetInstance('test').Commands.GetCommand('About').Execute = function() { return false; };
         };
   };
(function() {var fn = function() {$get("toolkitScriptManager_HiddenField").value = '';Sys.Application.remove_init(fn);};Sys.Application.add_init(fn);})();Sys.Application.add_init(function() {
    $create(Sys.Extended.UI.CalendarBehavior, {"button":$get("imageDateSelection"),"format":"MMMM d, yyyy","id":"calendarExtenderDateSelection"}, null, null, $get("textBoxDateSelection"));
});
//]]>
</script>

Here is the HTML from the source:

<textarea id="test" title="test" rows="5" cols="75" name="test"></textarea></div>

What I'm trying to do is clear the "test" ID in another function at the top of the document.

I'm able to read from it but just not delete it, I know this is an older piece of software but can someone please give me any code that may be able to accomplish this?

Thank you!!


Solution

  • Ok, I was able to figure this one out too, figure I put it here to let anyone know who may have a similar issue. First I find the TA then set a variable to it and clear it.

    var TA = FCKeiditorAPI.GetInstance('test'); //sets VAR to instance of TA
    TA.setData(""); // clears data from the TA