Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Triggering leave event when view is about to be removed

  • Loading branch information...
commit 95d803ec3478729e8e07cf18aa35040fa846d670 1 parent ea5ea57
@aroop aroop authored jferris committed
View
1  lib/assets/javascripts/backbone-support/composite_view.js
@@ -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();
View
13 spec/javascripts/composite_view_spec.js
@@ -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();
+ });
});
});
Please sign in to comment.
Something went wrong with that request. Please try again.