Permalink
Browse files

Triggering leave event when view is about to be removed

  • Loading branch information...
1 parent ea5ea57 commit 95d803ec3478729e8e07cf18aa35040fa846d670 @aroop aroop committed with jferris Oct 13, 2012
@@ -6,6 +6,7 @@ Support.CompositeView = function(options) {
_.extend(Support.CompositeView.prototype, Backbone.View.prototype, {
leave: function() {
+ this.trigger('leave');
this.unbind();
this.unbindFromAll();
this.remove();
@@ -184,5 +184,18 @@ describe("Support.CompositeView", function() {
expect(eventListener.called).toBeFalsy();
});
+
+ it("fires leave event", function() {
+ var eventListener = sinon.spy();
+ var view = new (Support.CompositeView.extend({
+ initialize: function(options) {
+ this.bindTo(this, 'leave', eventListener);
+ }
+ }))({model: {}});
+
+ view.leave();
+
+ expect(eventListener.called).toBeTruthy();
+ });
});
});

0 comments on commit 95d803e

Please sign in to comment.