Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#12566 closed Bug (invalid)

onClick event on fileButton causes an error after upload for minified version

Reported by: Brett Profitt Owned by:
Priority: Normal Milestone:
Component: General Version:
Keywords: Cc:


When uploading an image through the Image plugin with a custom filebrowserUploadUrl set, the following code causes an error (Uncaught TypeError: Cannot read property 'getDialog' of undefined on ckeditor.js:689) ONLY with the minified version:

CKEDITOR.on('dialogDefinition', function (ev) {
        var dialogName =;
        var dialogDefinition =;

        if (dialogName === 'image') {
                var uploadTab = dialogDefinition.getContents('Upload');

                for (var i = 0; i < uploadTab.elements.length; i++) {
                        var el = uploadTab.elements[i];

                        if (el.type !== 'fileButton') {

                        el.onClick = function() {

The error doesn't occur until after the server replies. This is what the reply looks like (with variables set correctly):

<script type='text/javascript'>$ckeditor_func_num, '{$params['url']}');</script>

Change History (5)

comment:1 Changed 9 years ago by Jakub Ś

Status: newpending
Version: 4.4.5

Could you send us simplified version of this custom upload code?

Please also make sure that response is returned in accordance with

comment:2 Changed 9 years ago by Brett Profitt

I'm not using FileUpload. I'm implementing the File Browser API as described here:!/guide/dev_file_browser_api

Here's a simplified version of the PHP code used to handle uploads:

$ckeditor_func_num = $_GET['CKEditorFuncNum'];

if ($_FILES['upload']['error'] === UPLOAD_ERR_OK) {
        if (move_uploaded_file($_FILES['upload']['tmp_name'], '/tmp/upload_test')) {
                // a static file
                $url = "http://localhost/example_file.png";
                echo "<script type='text/javascript'>$ckeditor_func_num, '$url');</script>";
        } else {
                echo "<script type='text/javascript'>$ckeditor_func_num, '', 'Error moving file.');</script>";
} else {
        echo "<script type='text/javascript'>$ckeditor_func_num, '', 'Error uploading file.');</script>";


comment:3 Changed 9 years ago by Brett Profitt

Resolution: invalid
Status: pendingclosed

I tracked this down to the difference in bind order when using minified vs non-minified versions stemming from how the plugins are loaded in the non-minified version. If you attach an onClick event handler to the fileButton input element, you need to call any existing event handlers.

Closing because I don't think there's anything that can be done in CK Editor to alleviate that.

comment:4 Changed 9 years ago by Jakub Ś

Thanks for letting us know.

If you attach an onClick event handler to the fileButton input element, you need to call any existing event handlers.

Could you perhaps try using this method:!/api/CKEDITOR.ui.dialog.uiElement-method-registerEvents. Perhaps it will solve your issue?

comment:5 Changed 9 years ago by Jérôme BLONDON

Hi, i was facing the same problem.

As a workaround i have directly put my custom buttons in the link plugin and re-minified my custom version with ckbuilder.

Note: See TracTickets for help on using tickets.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy