我想在route.js文件中的保存/更新操作後重新加載我的路由模型。以下是我的路線模型。Ember - 如何在保存/更新記錄後重新加載路徑模型
export default Ember.Route.extend({
model() {
return Ember.RSVP.hash({
employeeList : this.store.findAll('employee'),
employee : this.store.createRecord("employee"),
});
}
我試着跟着它不起作用。
this.refresh(); // I saw this in many posts.
任何人都可以建議如何在保存/更新操作後重新加載模型?
你想重新加載的原因是什麼?也許問題可以以不同的方式解決?順便說一句,「this.refresh()」在路線中工作。 –
我正在使用employeeList在模板中填充網格。但是在保存一條新記錄後,它不會填充到網格中。因此,考慮重新加載模型,以便它將再次獲取所有員工細節並在模板中顯示所有細節。 –
奇怪的是,新員工沒有在您的網格中顯示......我通常有一個創建新對象的子路由,所以也許這是一個計時任務。這適用於我:* route/employees.js *返回'this.store.findAll('employee')'而* route/employees/new.js *返回'this.store.createRecord('employee')'和它工作正常。你有選擇添加一條新路線嗎? –