Events 如何为Ext.Msg定义侦听器?
我已经在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.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();
你可以找到小提琴