Created
December 9, 2012 20:10
-
-
Save phawk/4246777 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
var app = app || { views: {} }; | |
app.views.MyView = Backbone.View.extend({ | |
initialize: function() { | |
app.events.bind("some-event", this.render, this); | |
}, | |
events: { | |
"click .reload": "render" | |
}, | |
render: function() { | |
this.$el.html(this.template(this.model.toJSON())); | |
}, | |
destroy: function() { | |
// Unbind the custom events | |
app.events.unbind("some-event", this.render); | |
} | |
}); | |
var myView = new app.views.MyView(); | |
// Cleanup the view safely | |
myView.destroy(); | |
myView.remove(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment