backbone.listenablemodel

Composite model for Backbone.js

npm install backbone.listenablemodel
17 downloads in the last month

Backbone.ListenableModel

Build Status Dependency Status

Nested listenable model for Backbone with proper event bubbling.

Listen to models the normal way

  var model = new Backbone.ListenableModel({
    value : true
  });

  model.on('change:value', function(){console.log('value changed!');});

Listen to submodel events

  var model = new Backbone.ListenableModel({
    value    : true,
    submodel : new Backbone.ListenableModel({
      subvalue : true
    });
  });

  model.on('change:value', function(){console.log('value changed!');});
  model.on('submodel.change:subvalue', function(){console.log('subvalue changed!');});

Also works with Backbone.Collection events!

npm loves you