In my controller
(ExtJS 4.2.1) I have a function where I create a window like this:
refs: [{
ref: 'holidayView',
selector: '[xtype=holiday.view]'
}],
init: function (application) {
this.control({
'[xtype=holiday.view] button#btnPrint': {
click: me.onPrint
}
});
},
onPrint: function () {
var me = this;
var window = Ext.create('Ext.window.Window', {
title: 'My Window',
itemId: 'myWindow',
width: 300,
height: 300,
modal: true,
layout: fit,
items: [{
xtype: 'panel'
}]
});
window.show();
},
otherFunction: function () {
var me = this;
// here I need to close the window
// I tried this:
var window = me.getHolidayView().up('#myWindow'); // but its undefined
// me.getHolidayView() is accesible
// I also have tried this:
var window = me.getHolidayView().down('#myWindow'); // also its undefined
}
Any clue on how to get the window component so I can close it?
Thanks-
UPDATE:
I tried this and it worked great but now sure if this is the right way:
var win = Ext.WindowManager.getActive();
if (win) {
win.close();
}