Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tinymce 4 and file_browser_callback

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);
    });
like image 435
user3646875 Avatar asked Jan 31 '26 12:01

user3646875


1 Answers

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
  });
like image 146
Chris Koston Avatar answered Feb 03 '26 11:02

Chris Koston