0
我有一个地址模型与1-1关系的员工模型。我想让Employee模型知道地址是否发生了一些变化,而这些变化正在被视图监听。如何触发骨干关联中嵌套模型的变化?
var Employee = Backbone.AssociatedModel.extend({
relations: [
{
type: Backbone.One, //nature of the relationship
key: 'manager', // attribute of Employee
relatedModel: 'Manager' //AssociatedModel for attribute key
}
],
defaults: {
age : 0,
fname : "",
lname : "",
manager : null
}
});
var Manager = Backbone.AssociatedModel.extend({
});
var EmployeeView = Backbone.View.extend({
initialize: function(){
this.model = new Employee();
this.listenTo(this.model, 'nested-change', this.render);
}
});
当Manager发生某些更改时,'嵌套更改'不起作用。请帮忙。