我正在使用以下代码从服务器获取模型:

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);


将此事件绑定到视图的initialize函数中

关于javascript - 提取后如何访问更改的属性? bone.js,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/23261438/

10-11 23:20
查看更多