我試圖通過回滾模型來捕獲和處理失敗的刪除請求,並讓它保留在視圖中,但我遇到了問題。我有我的控制器刪除行動如下:在失敗刪除後回滾模型不會更新視圖
model.delete();
model.save().then(function() {
alert('Deleted!');
}, function(err) {
alert('Delete failed...');
model.rollback();
});
這似乎做工精細,我可以看到,該模型迅速從商店中消失,然後立刻加回,但問題是它只是不會再出現在視圖中。
之前和之後刪除/回滾該模型具有以下屬性
isLoaded:true
isDirty: false
isSaving: false
isDeleted: false
isError: false
isNew: false
isValid: true
我的模板如下:
<table>
<thead>
<tr>
<th></th>
<th>Name</th>
<th>Number</th>
<th>Speed Dial</th>
</tr>
</thead>
<tbody>
{{#each contact in model}}
{{phonebook-row data=contact}}
{{/each}}
</tbody>
</table>
最後,這裏是在各自的路由模式掛鉤。
export default Ember.Route.extend({
model: function() {
return this.store.find('phonebook', { pageSize: 200 });
}
});
我在灰燼1.11.1和灰燼數據1.0.0-beta.16.1
這是預期的行爲,還是我失去了一些東西?任何信息,將不勝感激!
您是否嘗試過使用一個ember組件? –
你的觀點是什麼樣子? – GJK
@GJK沒有看法,但將我的模板添加到原始問題 – joshfarrant