using Backbone.js with Marionette.js (Go Derick Bailey!). Need to detect when a view is removed from the page. Specifically, I’m overwriting it with another view.
Is there an event I can detect of function I can overload to detect when this happens?
Thanks!
Marionette provides the
View.onClosemethod for this purpose:In vanilla Backbone you can override the
View.removemethod:Neither of these methods will work if you are simply clobbering the view’s DOM element. If that is your case, the solution is simple: Don’t do that. Remove the previous view explicitly before rendering another view in its place.