2
Beliebige Beispiele für persistierende neue Modell-Entität mit hasMany associacion? siehePersisting hasMany assoc in emberdata
Beliebige Beispiele für persistierende neue Modell-Entität mit hasMany associacion? siehePersisting hasMany assoc in emberdata
Hier ist ein Beispiel, http://jsfiddle.net/pangratz666/vuT2v/
App.Comment = DS.Model.extend({
text: DS.attr('string')
});
App.Post = DS.Model.extend({
title: DS.attr('string'),
comments: DS.hasMany('App.Comment')
});
var first = App.Comment.createRecord({
id: 'firstComment',
text: 'first comment'
});
var second = App.Comment.createRecord({
id: 'secondComment',
text: 'second comment'
});
var post = App.Post.createRecord({
id: 1,
title: 'post title'
});
var comments = post.get('comments');
comments.addObject(first);
comments.addObject(second);
App.store.commit();
Danke, aber ich brauche zu aktualisieren diese Objekte ... und die Standardimplementierung RESTAdapter tun es wie folgt aus: 'this.sideload (Speicher, Typ , json, root); ' ' store.didCreateRecord (modell, json [root]); ' und es ist seltsam POST-und GET-Anfrage für Kinder Elemente. mit anderen Worten - ich muss IDs für erstellte Elemente aktualisieren –