テンプレートのレンダリングが完了したときにDOMでいくつかのアクションをトリガーする必要があるため、ビューのdidInsertElementフックからモデルデータにアクセスしようとしています。
次のようなモデルで:
App.MyParent = DS.Model.extend({
title: DS.attr('string'),
childs: DS.hasMany('App.MyChild')
});
App.MyChild = DS.Model.extend({
name: DS.attr('string'),
parent: DS.belongsTo('App.MyParent')
});
そして次のようなオブジェクト:
App.MyParent.FIXTURES = [
{ id: 0, title: "some title", childs: [0,2,3] }
]
App.MyChild.FIXTURES = [
{ id: 0, name: "some name", parent: 0 },
{ id: 2, name: "other name", parent: 0 },
{ id: 3, name: "diff name", parent: 0 }
]
フック関数内で、次のようにchildsプロパティにアクセスしています。
var childs = this.get("context.content.childs");
次に、適切な数の子を持つ列挙型を取得しますが、子にはすべて未定義のプロパティがあります。
更新App.MyChild.find(someId) を使用して子にアクセスできる唯一の場所はブラウザー コンソールにあるようです。アプリ コードでは、未定義のプロパティを持つオブジェクトのみを取得します。
私は困惑しています!