Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Events 如何为Ext.Msg定义侦听器?_Events_Extjs_Listener - Fatal编程技术网

Events 如何为Ext.Msg定义侦听器?

Events 如何为Ext.Msg定义侦听器?,events,extjs,listener,Events,Extjs,Listener,我已经在Ext.Msg上定义了一些侦听器,但它们从未被解雇。有什么我不知道的吗 Ext.Msg.show({ title:'Save Changes?', message: 'You are closing a tab that has unsaved changes. Would you like to save your changes?', buttons: Ext.Msg.YESNO, icon: Ext.Msg.QUESTION, default

我已经在Ext.Msg上定义了一些侦听器,但它们从未被解雇。有什么我不知道的吗

Ext.Msg.show({
    title:'Save Changes?',
    message: 'You are closing a tab that has unsaved changes. Would you like to save your changes?',
    buttons: Ext.Msg.YESNO,
    icon: Ext.Msg.QUESTION,
    defaultListenerScope: true,
    fn: function(btn) {
        if (btn === 'yes') {
            console.log('Yes pressed');
        } else if (btn === 'no') {
            console.log('No pressed');
        } else {
            console.log('Cancel pressed');
        }
    },
    listeners: {
        activate: function(mb){
            console.log('Height: '+mb.getHeight()+' Width: '+mb.getWidth());
        },
        afterrender: function(mb){
            console.log('Height: '+mb.getHeight()+' Width: '+mb.getWidth());
        } 
    }
});

您正在
show()
上附加侦听器配置,这是
Ext.MessageBox
的一种方法,它没有任何类似侦听器的配置。您可以在MessageBox上附加侦听器,然后使用show()方法显示MessageBox。下面是显示行为的代码段

var myMsg = Ext.create('Ext.window.MessageBox', {        
   listeners: {
      activate: function(mb){
          console.log('Height: '+mb.getHeight()+' Width: '+mb.getWidth());
      },
      afterrender: function(mb){
          console.log('Height: '+mb.getHeight()+' Width: '+mb.getWidth());
      } 
   }
});

myMsg.show();
你可以找到小提琴