Last active
August 29, 2015 14:04
-
-
Save sagarpanda/6a5c997b7a755dbaea1a to your computer and use it in GitHub Desktop.
Backbone
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
| // Model Fetch | |
| App.models.User = new UserModel(); | |
| App.models.User.fetch({ | |
| data: { | |
| id: 1 | |
| }, | |
| success: (function () { | |
| console.log(' Service request success: '); | |
| }), | |
| error: (function (e) { | |
| console.log(' Service request failure: ' + e); | |
| }), | |
| complete: (function (e) { | |
| console.log(' Service request completed '); | |
| }) | |
| }); | |
| // Remove a view completely | |
| destroy_view: function() { | |
| // COMPLETELY UNBIND THE VIEW | |
| this.undelegateEvents(); | |
| this.$el.removeData().unbind(); | |
| // Remove view from DOM | |
| this.remove(); | |
| Backbone.View.prototype.remove.call(this); | |
| } | |
| // http://stackoverflow.com/questions/7379263/disposing-of-view-and-model-objects-in-backbone-js | |
| // http://workshop.unspace.ca/post/67567663306/avoiding-memory-leaks-in-backbone-js | |
| // https://github.com/powmedia/backbone-deep-model |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment