arturadib / agility

Javascript MVC for the "write less, do more" programmer
http://agilityjs.com
MIT License
542 stars 70 forks source link

destroy() does not propagate through children #57

Closed tristanls closed 12 years ago

tristanls commented 12 years ago

Hey @arturadib, I noticed that the destroy event isn't propagated to the children, so if I have a hierarchy like so

var child = $$( );
var parent = $$( );
var grandparent = $$( );

grandparent.append( parent );

parent.append( child );

then when I call grandparent.destroy(), the destroy event is never triggered for the child. Is there a specific design reason for this? I'm running into children not removing themselves as listeners, even though I thought they were being destroyed.

To clarify further, I have bound a pre:destroy event inside child to make sure it cleans up after itself in the application. But since destroy isn't getting called, the cleanup doesn't happen.