Skip to content

Instantly share code, notes, and snippets.

@sagarpanda
Last active August 29, 2015 14:04
Show Gist options
  • Select an option

  • Save sagarpanda/6a5c997b7a755dbaea1a to your computer and use it in GitHub Desktop.

Select an option

Save sagarpanda/6a5c997b7a755dbaea1a to your computer and use it in GitHub Desktop.
Backbone
// 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