backbone event bind

HTML

<script src="http://underscorejs.org/underscore.js"></script>
<script src="http://backbonejs.org/backbone-min.js"></script>
<script src="https://getfirebug.com/firebug-lite.js"></script>

CoffeeScript

class Animal extends Backbone.View
  vent: _.extend {}, Backbone.Events
    
  close: ->
    @model.off null, null, this if @model && @model.off
    @collection.off null, null, this if @collection && @collection.off
    @vent.off()
    @undelegateEvents()

class Cat extends Animal
  initialize: ->
    @events = _.extend @events, Animal::events
    @vent.on "animal", @barks, @

    super

  barks: (dog_barks) ->
    console.log dog_barks
    console.log "meow"
    @close()

class Dog extends Animal
  initialize: ->
    @events = _.extend @events, Animal::events

    super

  barks: ->
    @vent.trigger "animal", "bow"
    @close()

cat = new Cat()
dog = new Dog()
dog.barks()

delete window.cat

dog.barks()