Skip to content
This repository has been archived by the owner on Feb 14, 2018. It is now read-only.

Latest commit

 

History

History
36 lines (27 loc) · 1007 Bytes

README.md

File metadata and controls

36 lines (27 loc) · 1007 Bytes

Backbone.Listener

A simple plugin that adds a new object type for easily binding to events trigged on the Backbone object similar to how you can bind to DOM events with Backbone.View.

Build Status NPM version Coverage Status

Requirements

Backbone (tested with 1.1.2)

Example

var MyListener = Backbone.Listener.extend({

  events: {
    'bar': 'onBar',
    'foo': 'onFoo'
  },

  onBar: function(message) {
    console.log("onBar: " + message);
  },

  onFoo: function(message) {
    console.log("onFoo: " + message);
  }

});

var listener = new MyListener();

Backbone.trigger('foo', 'bar');
Backbone.trigger('bar', 'baz');