我使用此代码从服务器获取模型:
var id = args.model.get('id');
var options = {
action: 'getSubscriber',
address: args.model.get('address'),
silent: true
};
new Subscriber({ id: id }, options).fetch({
success: function(model, response) {
console.log(response);
console.log(model);
}
});
response
对象包含我需要的所有数据,而 model
将数据存储为 changed
对象,而不是其直接属性。这是错的吗?
通常我在 model.get('name')
调用的帮助下访问模型属性。在这种情况下如何访问新属性?应该是model.changed.thePropertyIwantToAccess
吗?
最佳答案
您可以使用此change
事件
this.model.on('change', function () {
var changedAttributes = this.model.changedAttributes();
//Process the changed attributes
}, this);
在View的initialize
函数中绑定(bind)该事件
关于javascript - 获取后如何访问更改的属性?主干.js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23261438/