Problem with removing a component that is Ext.dd.DropTarget
Problem with removing a component that is Ext.dd.DropTarget
Hi
In my application I have many components where I create an Ext.dd.DropTarget on their elements!
Some components may be later removed (e.g. a tab window closed). I have noticed that in the Ext.dd.DragDropMgr the 'ids' array which contains all elements in a ddGroup those components aren't removed!!!
The grid and tree with automatic DD are removed but not manually added components!
What would be the best way of emptying the Ext.dd.DragDopMgr ids array ? Is this a bug and should Ext manually handle this or am I maybe using the DropTarget wrong?
I hope it is understandable what the issue is, if not any questions are welcome!
thanks for help!
thanks Animal! was affraid this was the issue!
dropTarget.destroy() on beforeDestroy component does the trick!
Only question remains how to automate this process, since there is no point in keeping a dropTarget if the target is gone...or is it?
yes, but I manually added a listener to the component.
I was thinking more in the lines of overriding dropTarget constructor and adding there a before destroy listener to the linked component (have to figure out how to override constructors though ). But that would probably mess up some extended classes like TreeDropZone, so I'll probably drop that idea!
Thanks again for help.
Beware that the beforedestroy event and the beforeDestroy event do not guarantee that the component is going to get destroyed. If any of the listeners return false, the destroy process is stopped and you will have a half destroyed component, in your case, your drag and drop won't work.
It's not very common to stop the destroy process, but it's still possible.
The way I handle it is by overriding the destroy method, at that point, you're guaranteed that the component will be destroyed. You should do your destruction and the call the parent destroy method.