Created
June 18, 2012 17:25
-
-
Save anonymous/2949517 to your computer and use it in GitHub Desktop.
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
| // Virbone.View is a subclass of Backbone.View, with our own customizations of event-handling | |
| MyView = Virbone.View.extend({ | |
| modelEvents: { | |
| // the binding of modelEvents knows the special keywords | |
| // `model` and `collection` | |
| "change:data model": "onDataUpdate", | |
| "add collection": "onModelAdded", | |
| // if the subject is other than `model` and `collection`, | |
| // the subject-key is looked up in the options-object | |
| "change:otherData otherModelInOptions": "onOtherDataUpdate" | |
| }, | |
| // bind events to the pub/sub-system | |
| messengerEvents: { | |
| "page.new": "onNewPage" | |
| }, | |
| initialize: function() { | |
| this.addSubView("otherView", new OtherView()); | |
| }, | |
| teardown: function() { | |
| // this function will be called when the view is removed using remove(). | |
| // any custom events bound that is not model or messenger should be unbound here | |
| } | |
| }); | |
| myView = new MyView(); | |
| // Unbinds model and messenger updates and escaletas the remove-call to myView's subviews, and teardown() | |
| // is called for the view | |
| myView.remove(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment