Ember template not updating from arraycontroller

青春壹個敷衍的年華 提交于 2019-11-29 08:52:53

find (by query) doesn't actively make sure it has the records that match the query, so you'll have to manually inject it into the results.

createDescription: function () {
  var name = this.get('name'),
      friend_id = this.get('controllers.friend').get('id'),
      store = this.get('store'),
      description = store.createRecord('description', {
        name: name,
        friend_id: friend_id
      });
  description.save();
  this.pushObject(description);
},

or you can use a live record array (filter/all)

  model: function () {
    var store = this.get('store'),
        friend = this.modelFor('friend');
    store.find('description', {friend_id: friend.id});
    return store.filter('description', function(record){ 
       return record.get('friend_id') == friend.id;
    });
  }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!