, , . , createRecord embedded. .
createRecord, , created commit ember-data ajax .
, , ember-data, ajax-- Lesson Timeslot embedded , , ajax Timeslot, .
lesson = QrTimetable.Lesson.createRecord
group: group
lesson.set('timeslot', QrTimetable.Timeslot.createRecord())
lesson.store.commit()
-, ember-, , , .
, .
createRecord: function(store, type, record) {
var root = this.rootForType(type);
var data = {};
data[root] = this.serialize(record, { includeId: true });
this.ajax(this.buildURL(root), "POST", {
data: data,
context: this,
success: function(json) {
Ember.run(this, function(){
this.didCreateRecord(store, type, record, json);
});
},
error: function(xhr) {
this.didError(store, type, record, xhr);
}
});
},