Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

triggering leave event when a view is about to be removed #8

Closed
wants to merge 2 commits into from

2 participants

@aroop

No description provided.

@jferris
Admin

Thanks for the patch. This looks like it could be useful, but we only accept changes with tests. Would you like to write up a test for that new event?

@aroop

@jferris Test added. Thanks for considering to merge this.

@jferris
Admin

Thanks. I merged this in.

@jferris jferris closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 13, 2012
  1. @aroop
Commits on Oct 19, 2012
  1. @aroop
This page is out of date. Refresh to see the latest.
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();
+ });
});
});
Something went wrong with that request. Please try again.