简体   繁体   English

创建文件上传按钮时ckeditor错误

[英]ckeditor error while creating file upload button

I am using below code to create a ckeditor plugin to upload images. 我正在使用下面的代码来创建一个ckeditor插件来上传图像。 While i am trying to create a ckeditor dialog, I am getting below errors. 当我尝试创建ckeditor对话框时,出现以下错误。 Below piece of code i took from the below link. 下面的代码是我从下面的链接中提取的。 http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.dialog.definition.button.html http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.dialog.definition.button.html

In chrome : 在chrome中:

Uncaught TypeError: Cannot read property '_' of undefined 未捕获的TypeError:无法读取未定义的属性“ _”

In firefox : 在Firefox中:

b.getContentElement(...) is undefined b.getContentElement(...)未定义

Any help will be greateful. 任何帮助将是巨大的。

{
    type : 'file',
    id : 'upload',
    label : 'Select file from your computer',
    size : 38
},
{
    type : 'fileButton',
    id : 'fileId',
    label : 'Upload file',
    'for' : [ 'tab1', 'upload' ],
    filebrowser : {
        onSelect : function( fileUrl, data ) {
            alert( 'Successfully uploaded: ' + fileUrl );
        }
    }
},

I think that what you have there, is not "code" as it. 我认为您那里没有的是“代码”。 Is just the object definition you must do to initialize a button in a dialog, as the docs you pasted say: 正如您粘贴的文档所说,仅仅是初始化对话框中的按钮所必须执行的对象定义:

This class is not really part of the API. 此类实际上不是API的一部分。 It just illustrates the properties that developers can use to define and create buttons. 它仅说明了开发人员可以用来定义和创建按钮的属性。

Once the dialog is opened, the created element becomes a CKEDITOR.ui.dialog.button object and can be accessed with CKEDITOR.dialog#getContentElement. 打开对话框后,创建的元素将成为CKEDITOR.ui.dialog.button对象,可以使用CKEDITOR.dialog#getContentElement进行访问。 For a complete example of dialog definition, please check CKEDITOR.dialog.add. 有关对话框定义的完整示例,请检查CKEDITOR.dialog.add。

Then, if we check that: http://docs.ckeditor.com/#!/api/CKEDITOR.dialog.definition 然后,如果我们检查以下内容: http : //docs.ckeditor.com/#!/api/CKEDITOR.dialog.definition

We will find this code: 我们将找到以下代码:

CKEDITOR.dialog.add( 'testOnly', function( editor ) {
    return {
        title:          'Test Dialog',
        resizable:      CKEDITOR.DIALOG_RESIZE_BOTH,
        minWidth:       500,
        minHeight:      400,
        contents: [
            {
                id:         'tab1',
                label:      'First Tab',
                title:      'First Tab Title',
                accessKey:  'Q',
                elements: [
                    {
                        type:           'text',
                        label:          'Test Text 1',
                        id:             'testText1',
                        'default':      'hello world!'
                    }
                ]
            }
        ]
    };
} );

Then it seems you need to call the method CKEDITOR.dialog.add with the object you prepared. 然后似乎您需要使用准备好的对象调用方法CKEDITOR.dialog.add (anyway, I din´t checked all the data and the formats you have in your object) this example should work. (无论如何,我没有检查对象中所有的数据和格式)此示例应该可行。

Anyway, you should check this part of the same documentation and be sure on which one is the dialog/plugin you need. 无论如何,您应该检查同一文档的这一部分,并确保您需要哪个对话框/插件。

Hope it may help to you. 希望对您有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM