【发布时间】:2014-05-26 01:50:09
【问题描述】:
我有一个与多个翻译有一对多关系的模型:
App.Category = DS.Model.extend({
translation_ids: DS.hasMany('translation', { embedded: 'always' }),
});
App.Translation = DS.Model.extend({
name: DS.attr(),
locale: DS.attr()
});
我想根据所选语言获取类别名称:
App.CategoryController = Ember.ObjectController.extend({
needs: ['settings'],
currentLocale: Ember.computed.alias('controllers.settings.currentLocale'),
name: function() {
var translations = this.get('translation_ids').filterBy('locale', this.get('currentLocale'));
Ember.assert("Only one translation is expected", translations.length === 1);
return translations[0].get('name');
}.property('translation_ids')
});
一切都很顺利。但是当我编辑我的类别时,“名称”属性不会更新:
我已经尝试了一百万种不同的方法,但到目前为止都没有任何效果。有人能指出我的错误吗?
【问题讨论】:
标签: ember.js ember-data