Ember.js:live更新不适用于#each绑定到存储记录的子集

Ember.js: live update is not working for #each binding to a subset of store records

本文关键字:绑定 存储 记录 子集 #each 适用于 js live 更新 不适用 Ember      更新时间:2023-09-26

我很难为绑定到存储记录子集的{{#each}}助手进行实时更新,因此循环中使用的数据如下所示:

this.store.find('datainfo', {relId: 1})

每次添加新的datainfo时,循环显示的项目都不会更新。如果我删除了查询参数,这将正常工作。

以下是一个JSbin来说明这种情况:http://jsbin.com/megohu/13/edit

您可以在那里找到有关此行为的详细解释:http://emberjs.com/guides/models/frequently-asked-questions/#toc_how-do-i-inform-ember-data-about-news-records-created-on-the-backend

简而言之,自动更新的属性必须返回this.store.filterthis.store.all的结果,而不是this.store.findQuery

其中一种方法是获取Em.Route模型钩子中的所有this.store.findQuery,然后返回带有filter函数的this.store.filter

JSBin。