0
我有一個模型User
如下:嵌套的對象()`不受`DS.rollbackAttributes()`
import DS from 'ember-data';
const { attr, Model } = DS;
export default Model.extend({
name: attr("string"),
properties: attr(),
});
User.properties
旨在保持一個JSON對象。
我更新模型通過表單(使用ember-one-way-controls)如下:
{{one-way-textarea
model.name
update=(action (mut model.name))}}
{{one-way-textarea
model.properties.description
update=(action (mut model.properties.description))}}
我有一個按鈕,允許用戶通過調用discardChanges
行動放棄修改:
actions: {
discardChanges(model) {
model.rollbackAttributes();
},
},
name
屬性更改正確丟棄/重置,但properties
屬性不正確。
我該如何處理呢?
你也可以正確地稱這是一個錯誤,從一開始它已經存在。關於SO的問題一直是許多問題的主題。底線是你有人需要自己管理骯髒的子對象; 'notifyPropertyChange'是一個選項,如果現在還不推薦使用。 – 2016-12-20 15:17:35