Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

afoysal's avatar

onLoad or onShow event of ckeditor

I am displaying a tab Upload of Image Dialogue box using below code.

CKEDITOR.on( 'dialogDefinition', function( ev )
          {
              // Take the dialog name and its definition from the event  data.
              var dialogName = ev.data.name;
              var dialogDefinition = ev.data.definition;

              // Check if the definition is from the dialog we're
              // interested on (the "Link" dialog).
              if ( dialogName == 'image' )
              {
                dialogDefinition.dialog.resize( 700, 500 );
                // Add a new tab to the "Link" dialog.
                dialogDefinition.addContents({
                    id : 'uploadTab',
                    label : 'upload',
                    elements : [
                      {
                        type: 'text',
                        id: 'uploadField',
                        label: 'upload',     
                      }
                    ]
                });
              }
          });

error

Now I would like to catch onLoad event of Tab.

How can I do that ?

0 likes
2 replies
LaryAI's avatar
Level 58

You can use the onShow event to catch when the tab is shown. Here's an example:

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

    if ( dialogName == 'image' ) {
        dialogDefinition.dialog.on( 'showTab', function( evt ) {
            if ( evt.data.id == 'uploadTab' ) {
                console.log( 'Upload tab shown' );
                // Do something here
            }
        });

        dialogDefinition.addContents({
            id : 'uploadTab',
            label : 'upload',
            elements : [
                {
                    type: 'text',
                    id: 'uploadField',
                    label: 'upload',     
                }
            ]
        });
    }
});

In this example, we're using the on method to listen for the showTab event. When the event is fired, we check if the ID of the tab is uploadTab. If it is, we log a message to the console and do something else if needed.

Please or to participate in this conversation.