我有一个员工模型,他的地址模型有1-1关系。我想让员工模型知道地址中是否发生了某些变化,而这又是由视图监听的。
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发生某些变化时,它不起作用。请帮忙。