Вопрос 1 Что не так в моей концепции создания вложенной модели в ember-1.0.0-rc.1 + ember. данные-11?Вложенная модель [ember-1.0.0-rc.1 + ember.data-11]
Вопрос 2 С var line = App.Line.find() Я должен получить Линию. Как я могу получить Andon или Shift как Object, вложенные в строку? Или только цвет от Андона?
Здесь мой jsFiddle.
App.Line = DS.Model.extend({
name: DS.attr('string'),
shifts: DS.hasMany('App.Shift'),
});
App.Shift = DS.Model.extend({
name: DS.attr('string'),
// shift 1 <-> 1 shifts
line: DS.belongsTo('App.Line'),
// one-to-one relationship between Shift and Andon
andon: DS.belongsTo('App.Andon')
});
App.Andon = DS.Model.extend({
// one-to-one relationship between Shift and Andon
shift: DS.belongsTo('App.Shift')
})
Контроллер
App.LinesController = Ember.ArrayController.extend({
content: [],
});
App.linesController = Ember.ArrayController.create({
content: [],
init: function(){
var self = this;
self.pushObject(
App.Line.createRecord(
{
...
shifts: [
App.Shift.createRecord(
{
andon: App.Andon.createRecord({...})
}),
App.Shift.createRecord(
{
andon: App.Andon.createRecord({...})
}),
]
},
],
}
),
);
},
});
Спасибо большое!