'How can I detect onChange event in TinyMCE custom plugin it?

I'm trying to develop a custom TinyMCE plugin which will load the items for a selectbox list based on the options of another selectbox list. However, I cannot figure out how to detect any even on the selectbox list.

The documentation is almost entirely useless, as it provides no mention of custom plugin options - only the boilerplate code to start off.

How can I detect an onchange event when the select lists's selection is altered?

tinymce.PluginManager.add('custom', function(editor, url) {
    var openDialog = function () {
        return editor.windowManager.open({
            title: 'Custom',
            body: {
                type: 'panel',
                items: [
                    {
                        type: 'selectbox',
                        name: 'options',
                        label: 'Options',
                        items: [
                            {text: 'Primary', value: 'primay style'},
                            {text: 'Success', value: 'success style'},
                            {text: 'Error', value: 'error style'}
                        ],
                        onchange: function() {
                           alert('hi');
                        },
                        flex: true,
                    }, {
                        type: 'selectbox',
                        name: 'selection',
                        label: 'Selection',
                        items: [

                        ],
                        flex:true,
                    }
                ]
            },
            buttons: [
                {
                    type: 'cancel',
                    text: 'Close'
                },
                {
                    type: 'submit',
                    text: 'Save',
                    primary: true
                },
            ],

            onSubmit: function (api) {
                var data = api.getData();
                /* Insert content when the window form is submitted */
                editor.insertContent(data);
                api.close();
            }
        });
    };
    /* Add a button that opens a window */
    editor.ui.registry.addButton('custom', {
        text: 'Custom',
        onAction: function () {
            /* Open window */
            openDialog();
        }
    });
    /* Adds a menu item, which can then be included in any menu via the menu/menubar configuration 
*/
    editor.ui.registry.addMenuItem('custom', {
        text: 'Custom',
        onAction: function() {
            /* Open window */
            openDialog();
        }
    });
    /* Return the metadata for the help plugin */
    return {
        getMetadata: function () {
            return  {
                name: 'Example plugin',
                url: 'http://exampleplugindocsurl.com'
            };
        }
    };
});


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source