[ExtJS 3.4.0]
I have a class with prototypal intheritance to Ext.Window
, something like this:
function Cls_MyWindow() {
.....
var SaveButton = new Ext.Button({...});
var CancelButton= new Ext.Button({...});
.....
Cls_MyWindow.prototype.width = Ext.getBody().getWidth() - 800;
Cls_MyWindow.prototype.height = Ext.getBody().getHeight() - 350;
Cls_MyWindow.prototype.plain = true;
Cls_MyWindow.prototype.buttons = [SaveButton, CancelButton];
.....
}
Cls_MyWindow.prototype = new Ext.Window;
Cls_MyWindow.prototype.constructor = Ext.Window;
When this window is shown, it can be closed by pressing the CancelButton
or the built-in "x" button of Ext.Window
.
When I close it with CancelButton
, SaveButton
and CancelButton
get destroyed normally.
But, if is closed by the "x" button, the buttons cannot be destroyed, the loop is taking forever causing my application to crashed.
After some investigation I found, in ext-all-debug.js, this:
Ext.Panel = Ext.extend(Ext.Container, {
.....
if(Ext.isArray(this.buttons)){
while(this.buttons.length) {
Ext.destroy(this.buttons[0]);
}
}
.....
}
which invoke Ext.destroy
, this:
Ext.apply(Ext, function(){
.....
destroy : function(){
Ext.each(arguments, function(arg){
if(arg){
if(Ext.isArray(arg)){
this.destroy.apply(this, arg);
}else if(typeof arg.destroy == 'function'){
arg.destroy();
}else if(arg.dom){
arg.remove();
}
}
}, this);
},
.....
}());
What appears to be is that, this.buttons
-from pressing CancelButton- are Ext.Component thus, it get destroyed normally.
While this.buttons
-from pressing "x"- are not, which leads to the questions.
- Why
this.buttons
are not the same objects when it is destroy via different way? - What are the solution/options I have, if I want/need to retain the inheritance?
Shedding me some lights is most appreciated. Thank you in advance.