Skip to content

Commit

Permalink
Cleanup event listeners on destroy
Browse files Browse the repository at this point in the history
When a Model is destroyed, it may still be listening to events.
We should `stopListening` to those events to prevent memory leaks.
  • Loading branch information
emorikawa committed Jul 14, 2014
1 parent bc59f53 commit 028a066
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions backbone.js
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,7 @@
var success = options.success;

var destroy = function() {
model.stopListening();
model.trigger('destroy', model, model.collection, options);
};

Expand Down

0 comments on commit 028a066

Please sign in to comment.