PDA

View Full Version : Removing component and adding new instance of same component back in gives error



Drömbolaget
15 Oct 2013, 2:21 AM
I have a container with an item in it that has been added with .add() and crated dynamically.

If I do container.removeAll(true); and later add a new instance of my item, the error log shows:


Uncaught TypeError: Cannot read property 'addCls' of null

The layout is not completed and the new component is not shown. The problem is noted in the documentation (http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.container.AbstractContainer-method-removeAll).

The problem seems to be that ExtJS tries to render the previous item that was destroyed. See screenshot of debugging.

46329

I belive this bug report could also be related (http://www.sencha.com/forum/showthread.php?260876-addcls-null-error-with-textfield-when-handling-isdirty-change).

I cannot get this to happen in a simpler example than my real application though...

Drömbolaget
15 Oct 2013, 2:29 AM
Never mind, the new instance wasn't a new instance, it was the old instance that was destroyed.

One could argue that adding a destroyed component shouldn't explode but give a nice error hint. But anyway.