PDA

View Full Version : Problems with removeAll() and Add() ??



realjax
1 Feb 2010, 1:32 AM
Try this code:



// a menu
var accordionMenu = [{
title: 'item',
border: false,
collapsible: true,
padding: 0,
align: 'center',
items: new Ext.menu.Menu({
floating: false,
autoHeight: true,
cls: 'x-menu',
items: [{
text: 'anItem'
}, {
text: 'anotherItem'
}]
})
}, {
title: 'item 2',
border: false,
items: new Ext.menu.Menu({
floating: false,
autoHeight: true,
cls: 'x-menu',
items: [{
text: 'anItem'
}, {
text: 'anotherItem'
}]
})
}
];

var aWindow = new Ext.Window({
layout:'accordion',
width:500,
height:300,
items:accordionMenu
});

aWindow.show(this);

// then remove all items

aWindow.removeAll();

// add them again

aWindow.add(accordionMenu);

// and doLayout()
aWindow.doLayout();
This results in this errormessage in firebug:

TypeError: c.el.up("li.x-menu-list-item", 5) is null { message="c.el.up("li.x-menu-list-item", 5) is null", more...}

However....

when you replace


aWindow.add(accordionMenu); with te actual value of the array so it becomes:



aWindow.add([{
title: 'item',
border: false,
collapsible: true,
padding: 0,
align: 'center',
items: new Ext.menu.Menu({
floating: false,
autoHeight: true,
cls: 'x-menu',
items: [{
text: 'anItem'
}, {
text: 'anotherItem'
}]
})
}, {
title: 'item 2',
border: false,
items: new Ext.menu.Menu({
floating: false,
autoHeight: true,
cls: 'x-menu',
items: [{
text: 'anItem'
}, {
text: 'anotherItem'
}]
})
}
])
Then all of a sudden everything works just fine...


ps. tried this with Extjs 3.0 3.03 and 3.1 and they all show same behavior..

realjax
1 Feb 2010, 7:55 AM
Further info:

The above mentioned errormessage occurs when this code is run from Firebugs console.

Running from within my application this error occurs:

this.dom is undefined

and resolves to this line in ext-debug




findParentNode : function(simpleSelector, maxDepth, returnEl){
var p = Ext.fly(this.dom.parentNode, '_internal');
.....

Line 4949 (Extjs 3.0)

realjax
2 Feb 2010, 12:32 AM
It is likely related to a destroy() method that doesn't work quite well.
Can anyone say something sensible on this subject ?

realjax
2 Feb 2010, 4:47 AM
I moved it to Bugs.

Might as well close this

thanks.