我想在打开其他窗口之前先关闭窗口,我已经尝试过了,但是不起作用,有没有人可以帮助我?
我的代码片段:
listeners: {
click: function() {
var win = new Ext.window.Window({
constrain: true,
height: 300,
title: 'Window',
width: 300,
closeAction: 'hide'
});
if (win.isVisible() !== true) {
win.show();
} else {
win.close();
}
}
}
发布于 2016-10-21 09:34:18
您可以使用Ext.WindowManager
。
Ext.create('Ext.Button', {
text: 'Click me',
renderTo: Ext.getBody(),
listeners: {
click: function() {
Ext.WindowManager.each(function(cmp) {
cmp.close();
});
Ext.create('Ext.window.Window', {
constrain: true,
height: 300,
title: 'Window',
width: 300,
closeAction: 'hide'
}).show();
}
}
})
<script src="http://cdn.sencha.com/ext/gpl/4.2.0/ext-all.js"></script>
<link href="http://cdn.sencha.com/ext/gpl/4.2.0/resources/css/ext-all.css" rel="stylesheet" />
发布于 2016-10-21 09:10:02
var win = new Ext.window.Window({
constrain: true,
height: 300,
title: 'Window',
width: 300,
closeAction: 'hide',
listeners:{
beforeclose:function(){
Ext.Msg.alert('Close','You\'re closing Window',function(){
var win2== new Ext.window.Window({
constrain: true,
height: 300,
title: 'Window2',
width: 300,
closeAction: 'hide'
});
win2.show();
});
}
}
});
win.show();
发布于 2016-12-08 11:58:27
您需要将beforeclose
事件添加到窗口中。在其中调用新窗口。
Ext.application({
name: 'Fiddle',
launch: function() {
let i = 1;
function create_window(title) {
var win = new Ext.window.Window({
constrain: true,
height: 150,
title: 'Window ' + title,
width: 300,
closeAction: 'hide',
listeners: {
beforeclose: function (sender, options) {
i++;
create_window(i);
return true;
}
}
});
if (win.isVisible() !== true) {
win.show();
} else {
win.close();
}
}
create_window(i);
}
});
<script src="http://cdn.sencha.com/ext/gpl/4.2.0/ext-all.js"></script>
<link type="text/css" rel="stylesheet" href="http://cdn.sencha.com/ext/gpl/4.2.0/resources/css/ext-all.css")/>
https://stackoverflow.com/questions/40172233
复制相似问题