我想在打开其他窗口之前关闭窗口,我试图按照下面的方式做但不起作用,是否有人可以帮助我?
我的代码片段:
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();
}
}
}
答案 0 :(得分:1)
您可以使用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" />
答案 1 :(得分:0)
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();
答案 2 :(得分:0)
您需要将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")/>