我的观点之一有以下代码:
this.model.on('change:id', this.itemIdChanged, this );
itemIdChanged: function(){
if(this.model.hasChanged('id')) {
var that = this;
this.model.fetch({
success: function (item) {
that.render();
}
})
}
},
所以一旦我改变了这个模型的id,它就会调用render两次,一次是我设置id时,另一次是在获取成功块时。这是非常令人不安的,因为它调用了两次渲染,这在眼睛中很烦人并且很浪费。我怎样才能避免这种情况?