Closed jasonwebster closed 10 years ago
From jQuery docs:
In addition to the elements themselves, all bound events and jQuery data associated with the elements are removed. To remove the elements without removing data and events, use .detach() instead.
Released in v3.0.0-alpha.1
I'm using a LayoutView where I'm retaining the views, so they are not destroyed on change. However,
setView
will still nuke all DOM events bound to the view's element due to it callingoldView.$el.remove()
.2 lines later, it also calls
this._removeChild(oldView)
which will call_destroy
on the old view if the retain count is zero (which in turn callsBackbone.View.prototype.remove()
, which in turn calls$el.remove
).Current functionality is preserved and reusing view instances is not buggy if we simply change:
oldView.$el && oldView.$el.remove()
to
oldView.$el && oldView.$el.detach()
https://github.com/walmartlabs/thorax/blob/master/src/layout.js#L33