View Full Version : [2.0b1][SOLVED] That may be Container's bug

22 Oct 2007, 5:16 AM
Ext.onReady(function() {
var p = new Ext.Panel({
title: "Inner Panel",
el: "panel-a"
var win = new Ext.Window({
title: "Test Window",
width: 300,
height: 200,
items: p
p.on("destroy", function(){
alert("Inner panel destroyed!");
win.on("destroy", function(){
alert("Test window destroyed!");

When the window destroyed, the inner panel should also be destroyed and fire itself's "destroy" event. But in fact the panel's "destroy" event is not fired.

It's the same when using a Panel, or a TabPanel ... as a container.

Is that a bug of the Container component?

22 Oct 2007, 5:17 AM
I'm sorry, I have post it twice:">

22 Oct 2007, 5:28 AM
OK, I got rid of the other one.

Jack, the problem is that Container.onDestroy calls Ext.destroy on all of it's child Components.

But Ext.destroy attempts to call destroy on what you pass it. Components use onDestroy.

22 Oct 2007, 1:55 PM
Components use destroy(), onDestroy is just an internal template method. destroy() is defined on Component.

I believe this is related to another issues already fixed in SVN. The probem was the destroy event never gets fired.

22 Oct 2007, 2:22 PM
I've stepped through it.

The inner Panel is being destroyed, but its listeners are being removed, so the listener function is never invoked because

Container calls Ext.destroy on all its children. Ext.destroy calls purgeListeners on the passed argument before calling its destroy method.

22 Oct 2007, 2:23 PM
Sweet. Thanks animal.

22 Oct 2007, 2:27 PM
I removed the call to purgeListeners since classes should handle that themselves internally (like Component does).