Created
December 4, 2012 18:09
-
-
Save MikeLarned/4207032 to your computer and use it in GitHub Desktop.
LayoutManagerCleanViews
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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