我有一个非常简单的模型,称为“gameModel”和一个集合“gamesCollection”,如下所示。当我尝试在集合中创建一个新游戏时,它会向服务器发送一个帖子,但该帖子中没有数据。有谁知道发生了什么?
//The relevant code
var game = new gameModel();
game.gameId = id;
gamesCollection.create(game);
...........
//The Collection
define([
'jQuery',
'Underscore',
'Backbone',
'collections/common/mixin',
'models/game',
'config/restresource'
], function($, _, Backbone, collectionMixin, gameModel, restDomain){
var gamesCollection = Backbone.Collection.extend({
url: (new restDomain()).getGamesRoot(),
model: gameModel,
initialize: function(){
_.extend(this.__proto__, collectionMixin);
},
parse: function(resp, xhr) {
var games = [];
for(i=0;i<resp.length;i++){
games.push(new gameModel({gameId: resp[i].gameId}));
}
return games;
},
});
return new gamesCollection;
});