1

Topic: Uncaught TypeError: Cannot call method 'apply' of undefined

Hi guys, when I try to save the content of the textarea I get this error in Google Chrome (Uncaught TypeError: Cannot call method 'apply' of undefined) and this in Mozilla Firefox with Firebug extension (f is undefined  "return f.apply(s || t, Array.prototype.slice.call(arguments, 1));" )


This is an app built using Spring MVC architecture, with JSP pages as user frontend.

The textbox to be transformed into the editor is defined in a .jsp as following (this is the complete JSP):

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr">

    <body>
        <div id="initScriptEditor"></div>
        <div>
            <form id="tabEditorForm">
                <textarea id="editorId" name="content" cols="150" rows="30">

                </textarea>
            </form>
        </div>
    </body>
</html>


I initiated the editor in a .js file loaded dynamically with Ajax, as following:
    tinyMCE
   .init(
   {
       language : "it",
      mode : "exact",
      elements : "editorId",
      theme : "advanced",
      plugins : "emotions,spellchecker,advhr,insertdatetime,preview, print, table, template,save",
      save_onsavecallback : "postEditor('/DeliDete/saveEditor','','tabEditorForm','initScriptEditor')",
      // Theme options - button# indicated the row# only
      theme_advanced_buttons1 : "newdocument,|,cut,copy,paste,|,undo,redo,|,bullist,numlist,|,bold,italic,underline,|,justifyleft,justifycenter,justifyright,fontselect,fontsizeselect,formatselect",
      theme_advanced_buttons2 : "outdent,indent,|,image,|,preview,|,forecolor,backcolor,|,insertdate,inserttime,|,advhr,,removeformat,|,sub,sup,|,charmap,print,|,template,|,save,cancel",
      theme_advanced_buttons3 : "tablecontrols,table,row_props,cell_props,delete_col,delete_row,col_after,col_before,row_after,row_before,split_cells,merge_cells",
      theme_advanced_toolbar_location : "top",
      theme_advanced_toolbar_align : "left",
      theme_advanced_resizing : true
   });

In the same file I have defined the callback function to be called, defined as following:

function postEditor(url, parameters, formName, initScript)
{
......
}

Is there anything I am doing wrong?
Thanks for your help!

2

Re: Uncaught TypeError: Cannot call method 'apply' of undefined

EDIT:
added some debug lines in the src version of tiny_mce and this is what I found:

if (is(f, 'string'))
{
   alert("tiny_mce_src.js 11200 f: " + f); ---> tiny_mce_src.js line 11200 f: postEditor('/DeliDete/saveEditor','','tabEditorForm','initScriptEditor')

   s = f.replace(/\.\w+$/, '');
   alert("tiny_mce_src.js 11202 s: " + s); ---> tiny_mce_src.js line 11202 s: postEditor('/DeliDete/saveEditor','','tabEditorForm','initScriptEditor')
   
   s = s ? tinymce.resolve(s) : 0;
   alert("tiny_mce_src.js 11204 s: " + s); ---> tiny_mce_src.js 11204 s: undefined
   
   f = tinymce.resolve(f);
   alert("tiny_mce_src.js 11206 f: " + f); ---> tiny_mce_src.js 11206 f: undefined

   t.callbackLookup = t.callbackLookup || {};
   t.callbackLookup[n] = {func : f, scope : s};
}

3

Re: Uncaught TypeError: Cannot call method 'apply' of undefined

Fix your incorrect save_onsavecallback option value. Should be a function name or a function referece.

Best regards,
Spocke - Main developer of TinyMCE

4

Re: Uncaught TypeError: Cannot call method 'apply' of undefined

So you are telling me I cannot pass parameters to the function I'm calling?
Thanks for your help!