4 ms·
Yes, but if they are bound to the child's element and that is removed shouldn't that be sufficient unless the view is binding to other elements or window events
by andrewvc 14y ago
Yes, but if they are bound to the child's element and that is removed shouldn't that be sufficient unless the view is binding to other elements or window events?
- sim0n 14y agoBackbone Views often bind to model/collection events.
- m64253 14y agoIt's quite common to bind to events on objects like models or collections etc. which will not be unbound just because the dom element is.
- Flow 14y agoIsn't that true only for older Internet Explorer versions because they had two garbage collectors, one for DOM stuff and one for JScript stuff?
- chrizel 14y agoThat's not a problem just for IE. It's a problem that browser vendors could only solve by giving us WeakMaps (which could come in ES6 http://wiki.ecmascript.org/doku.php?id=harmony:weak_maps#weakmap http://wiki.ecmascript.org/doku.php?id=harmony:weak_maps#wea... )... The problem is, you have a bunch of subviews which are registering events on some collection models... when you rerender your parent view your subviews get recreated but your previously created subviews stay in memory because the backbone events system still stores references to the old views which aren't really needed anymore. The only solution is to explicitly remove the events when subviews a destroyed (or better use a solution like in the submitted article) or use a library like https://github.com/marionettejs/backbone.eventbinder https://github.com/marionettejs/backbone.eventbinder