How to use the CKFinder Javascript api?

China☆狼群 提交于 2019-12-05 13:02:29

As stated in the Documentation you may not be able to access it directly, instead you should call any Folder API function once CKFinder object has been loaded.

Note: the CKFinder.dataTypes namespace is not directly accessible (CKFinder.dataTypes is undefined). Data types are used internally by CKFinder and returned by many functions, like CKFinderAPI#getSelectedFolder.


The following example is an initialization in javascript of the CKFinder component which shows how to access the Folder datatype.

<script type="text/javascript">
    var finder = new CKFinder();
    finder.basePath = '/js/ckfinder/'; // The path for the installation of CKFinder (default = "/ckfinder/").
    // Setting custom width and user language.
    finder.width = '99%';
    finder.defaultLanguage = 'es';
    finder.language = 'es';

    finder.removePlugins = 'basket';
    //finder.selectActionFunction = showFileInfo;
    //finder.resourceType = 'Images';
    //finder.tabIndex = 1;
    //finder.startupPath = "Images:/";

    finder.callback = function( api ) 
    {
        api.openMsgDialog( "", "Almost ready to go!" );
        api.hideTool( "f2" );//hide flash folder
        api.openFolder('Images', '/');
        var folder = api.getSelectedFolder();
        //console.debug(folder);
        folder.createNewFolder( 'New Folder' );
        //api.setUiColor('white');
    };
    var api = (finder).create();

    //console.debug(api);
    //api.openMsgDialog("Sample title","Sample message."); //doesnt work here, CKFinder still not loaded.
</script>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!