PDA

View Full Version : ExtJs 3.1 Javascript error in menu



gaetan
28 Dec 2009, 5:53 PM
In Examples /Desktop

in you insert this code in any sample window :


if(!win){

var tb = new Ext.Toolbar([
{
text: 'File',
iconCls: 'icon-grid',
menu: {
items: [
{
text: 'Quit',
iconCls: 'quit',
handler: function() {win.close();}
}
]
}
}
]);

...

win = desktop.createWindow({
id: 'grid-win',
title:'Grid Window',
width:740,
height:480,
iconCls: 'icon-grid',
shim:false,
animCollapse:false,
constrainHeader:true,
tbar: tb,
layout: 'fit',

...



I get this javascript error in firebug : "me.dom is undefined" when I click the Quit button.
If I close the window via the X tool, all is OK.



me.dom is undefined
anonymous(["x-hide-offsets" 0=x-hide-offsets])ext-all-debug.js (ligne 3844)
anonymous()ext-all-debug.js (ligne 9785)
anonymous()ext-all-debug.js (ligne 34320)
anonymous()ext-all-debug.js (ligne 9779)
anonymous()ext-all-debug.js (ligne 9769)
anonymous(true)ext-all-debug.js (ligne 34314)
anonymous()ext-base.js (ligne 7)
[Break on this error] me.dom.className += (!me.hasClass(v) && v ? " " + v : "");\n


But if I don't use sub menu like this



var tb = new Ext.Toolbar([
{
text: 'Quit',
iconCls: 'quit',
handler: function() {win.close();}
}
]);



All is OK, no error.

Could somebody help ?

Thanks

gaetan
30 Dec 2009, 2:18 AM
Nobody ?
Is it working for everybody but me ?

Condor
30 Dec 2009, 2:22 AM
You can't destroy the window from the menu handler, because the code that follows the menu handler call still expects the menu and button to exist.

I suggest you delay destroying the window until the handler is done, e.g.

var tb = new Ext.Toolbar([{
text: 'Quit',
iconCls: 'quit',
handler: function(){
win.close.defer(10, win);
}
}]);

kronian
30 Dec 2009, 3:05 AM
...but vers 3.0.3 seems to be going right :-?

gaetan
30 Dec 2009, 3:17 AM
Yes, this was working for all releases prior to 3.1.0

gaetan
30 Dec 2009, 3:23 AM
Condor, thanks for your help.
I had to put a value of 100 in the defer call, and it's working.