View Full Version : Container.destory Bug (with fix)?

4 Jul 2010, 4:55 AM
I have a Container, that I cann removeAll on. This, in turn calls destroy on the contained items.

However, I'm getting an error on ext-touch-debug.js, line 13937. The error says:

TypeError: Result of expression 'this.items.first' [undefined] is not a function.

This can be fixed by checking for null as follows.

beforeDestroy : function() {
var c;
if (this.items) {
if(this.items.first == null){return;} //ADDED THIS LINE
c = this.items.first();
while (c) {
this.doRemove(c, true);
c = this.items.first();

I wanted to know if there's any other reason why the items.first might be null? Maybe I'm using it wrong so the monkey patch isn't applicable :)


5 Jul 2010, 1:51 PM
It means that this.items is not a MixedCollection. I don't see how this could happen as we call initItems, which makes items a mixedcollection, at the end of initComponent so items should always have the first method. Would it be possible for us to see your source code?