draduc
19 Jan 2010, 6:58 AM
The code i used for the test:
Ext.onReady(function(){
Ext.getDoc().on({
'contextmenu':{
scope:this,
fn:function(e){
e.preventDefault();
if(!this.testMenu){
this.testMenu = new Ext.menu.Menu({
items:[
{
text:'destroy menu',
scope:this,
handler:function(){
this.testMenu.destroy();
}
}
]
});
Ext.util.Observable.capture(this.testMenu,function(eventName){
console.log('menu fire: ' + eventName);
});
this.testMenu.showAt(e.getXY());
}
}
}
});
});
The problem: Throws the following JS error :
me.dom is undefined
.../script/lib/ext/ext-all-debug.js
Line 3844
The cause: The menu beforehide / hide set of events fires after the beforedestroy/destroy set of events as shown by the console output posted below
...
menu fire: mouseout
menu fire: mouseover
menu fire: beforedestroy
menu fire: destroy
menu fire: itemclick
menu fire: click
menu fire: beforehide
Suggested resolution: hide the menu before the handler is executed. As i'm not using any special menu items, this workaround seems to mask the problem.
The above case is the most obvious one, however, the same error appears when clicking a menu item triggers the destruction of a component that it is bound to.
Thank you!
Ext.onReady(function(){
Ext.getDoc().on({
'contextmenu':{
scope:this,
fn:function(e){
e.preventDefault();
if(!this.testMenu){
this.testMenu = new Ext.menu.Menu({
items:[
{
text:'destroy menu',
scope:this,
handler:function(){
this.testMenu.destroy();
}
}
]
});
Ext.util.Observable.capture(this.testMenu,function(eventName){
console.log('menu fire: ' + eventName);
});
this.testMenu.showAt(e.getXY());
}
}
}
});
});
The problem: Throws the following JS error :
me.dom is undefined
.../script/lib/ext/ext-all-debug.js
Line 3844
The cause: The menu beforehide / hide set of events fires after the beforedestroy/destroy set of events as shown by the console output posted below
...
menu fire: mouseout
menu fire: mouseover
menu fire: beforedestroy
menu fire: destroy
menu fire: itemclick
menu fire: click
menu fire: beforehide
Suggested resolution: hide the menu before the handler is executed. As i'm not using any special menu items, this workaround seems to mask the problem.
The above case is the most obvious one, however, the same error appears when clicking a menu item triggers the destruction of a component that it is bound to.
Thank you!