Skip to content

Instantly share code, notes, and snippets.

@MikeLarned
Created December 4, 2012 18:09
Show Gist options
  • Select an option

  • Save MikeLarned/4207032 to your computer and use it in GitHub Desktop.

Select an option

Save MikeLarned/4207032 to your computer and use it in GitHub Desktop.
LayoutManagerCleanViews
cleanViews: function(views) {
// Clear out all existing views.
_.each(aConcat.call([], views), function(view) {
// Remove all custom events attached to this View.
view.unbind();
// Automatically unbind `model`.
if (view.model instanceof Backbone.Model) {
view.model.off(null, null, view);
}
// Automatically unbind `collection`.
if (view.collection instanceof Backbone.Collection) {
view.collection.off(null, null, view);
}
// If a custom cleanup method was provided on the view, call it after
// the initial cleanup is done
if (view.cleanup) {
view.cleanup.call(view);
}
});
},
from https://github.com/tbranyen/backbone.layoutmanager using in example
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment