Q:

change event in backbone relational not working

I am working with backbone relational with HasMany relationship. Add event gets fired but change event does not.
Model1 = Backbone.RelationalModel.extend({
    urlRoot: '/Leve1/',

    initialize: function () {
        this.listenTo(this, 'add:relatedModels', this.relationModelAdd);
        this.listenTo(this, 'change:relatedModels', this.relationModelChange);
    },

    relations: [{
        type: Backbone.HasMany,
        key: 'relatedModels',
        relatedModel: 'InnerModel'
    }],

    relationModelAdd: function () {
        alert("Add in related model");
    },

    relationModelChange: function () {
        alert("Change in related model");
    }
});

InnerModel = Backbone.RelationalModel.extend({
    urlRoot: '/Level2/'         
});

var outerModel = new Model1({
    id: 'model1',
});
var innerModel = new InnerModel({
    id: 'model11',          
});

outerModel.get('relatedModels').add(innerModel);

innerModel.set({
    id: 'model13'
});

Change event with HasOne relationship works but not with HasMany.

A:

It seems, change event does not fire on a outer-model Model1 if change occurs in any model InnerModel inside a HasMany relation's collection. See the issue in Backbone.RelationalModel on GitHub: Change events not being fired on collection change. The issue was closed by the author who said:

I don't think firing a change event for every modification on any relation by defaults would be a good idea, but something like that is pretty easy to do by adding a helper method to  Backbone.RelationalModel, since this._relations actually does give you the related model or collection. Quick first attempt that you could build from:
Backbone.RelationalModel.prototype.bindRelationEvents = function() {
    var dit = this;
    _.each( this.getRelations(), function( relation ) {
        relation.related && relation.related.bind( 'all', function() {
            dit.trigger.apply( dit, arguments );
            // Or even simply `dit.render()`, if the number of events is reasonable...
        } );
    });
};

then call this.bindRelationEvents for objects you'd like to receive all events from their relations as well.

