extjsextjs5

Passing a variable to a button's handler


In my interface i have created this button :

{
        xtype: 'button',
        width: 196,
        height: 29,
        hidden: false,
        text: Strings.sharedNotifications,
        glyph: 'xf003@FontAwesome',
        handler: 'onNotificationsClick',
        reference: 'settingsNotificationsButton',
        cls: 'buttonsCls',
         id : 'settingsMenuButton7'
    }

And in the controller i define this function as the handler for the above button :

 onNotificationsClick: function () {
                Ext.create('Mine.view.BaseWindow', {
                    title: Strings.sharedNotifications,
                    items: {
                        xtype: 'notificationsView'
                    }
                }).show();
            },

I want to apply an additional style (add a CSS class with addCls method) on the panel it gets displayed on click depending on some global variable defined in the controller. How to pass the variable (say var dark;) to the onNotificationsClick in order to style the panel on click. Thanks


Solution

  • I would fire an event in the handler. When you fire the event you can pass arguments.

    Here is a fiddle.