3

Im' trying to do a function file_browser_callback, mais it's seem's not working :

In my browser :

Uncaught TypeError: a is not a function

Function call :

function elFinderBrowser (field_name, url, type, win) {
    tinymce.activeEditor.windowManager.open({
        file:"http://stores-concept:8899/app_dev.php/admin/elfinder/tinycme",
        title: "elFinder 2.0",
        width: 900,
        height: 450,
        resizable: 'yes'
    }, {
        setUrl: function (url) {
            win.document.getElementById(field_name).value = url;
        }
    });
    return false;
}

And my tiny init :

    jQuery(document).ready(function($) {
        var $configs = {"language":"fr","file_browser_callback":"elFinderBrowser","plugins":"bootstrap code codemirror fullscreen preview table visualblocks link image media","toolbar1":"styleselect | bold italic | fontsizeselect | alignleft aligncenter alignright alignjustify | link image media | bootstrap | code preview","menubar":false,"toolbar_items_size":"small","codemirror":"path: \"CodeMirror\"","script_url":"\/bundles\/whadmin\/js\/plugin\/tinymce\/tinymce.min.js"};
        var $textarea = jQuery('#wh_cmsbundle_page_body');
        if($textarea.is('[required]')) {
            $configs.oninit = function(editor) {
                editor.onChange.add(function(ed, l) { ed.save(); });
            };
        }
        $textarea.tinymce($configs);
    });
4
  • Where is this error thrown? Can you show the code that throws it? Oct 23, 2015 at 10:59
  • "Uncaught TypeError: a is not a function" Oct 25, 2015 at 4:10
  • Nothing else. Only "a is not a function" Oct 25, 2015 at 4:11
  • Same here, really annoying... Nov 9, 2015 at 0:56

3 Answers 3

5

Figured it out. The example in the TinyMCE manual is wrong! They provide custom callback as string. From TinyMCE manual:

 tinyMCE.init({
    theme : ...,
    mode: ...,

    file_browser_callback : 'myFileBrowser'
  });

which is totally wrong, callback should be a function not a string. So the proper example would be:

 tinyMCE.init({
    theme : ...,
    mode: ...,

    file_browser_callback : myFileBrowser
  });
0
1

I tried like this and it worked.

file_browser_callback: function (fieldName, url, type, win) {
            alert("Test");
        }
1

You can also use the following method:

<script>

var myBrowser = function(field_name, url, type, win) {
    alert('Hello');
}

tinymce.init({
    file_browser_callback: myBrowser
)};

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.