我在使用Ember应用程序更新模型时遇到了很多麻烦。我似乎无法找到描述如何更新我的应用的好文档。以下代码是我尝试的。这会向/ playlists /:playlist_id发送更新,遗憾的是它也没有发送更新后的歌曲...是否有一些我无法找到的pushObject回调?我试图保存错误的东西吗?
App.PlaylistIndexController = Ember.ObjectController.extend({
actions: {
addSong: function(song) {
songs = this.get('songs');
songs.pushObject(song);
this.get('model').save();
}
}
});
App.Playlist = DS.Model.extend({
name: DS.attr('string'),
songs: DS.hasMany('song'),
});
App.Song = DS.Model.extend({
name: DS.attr('string'),
artist: DS.attr('string'),
playlist: DS.belongsTo('playlist'),
});