The server response should be like this:
{ _id : 111 }
Because you set _id as the primary key. When the model is selected, check the _id value, which should have a value: console.log (model.get ('_ id'));
My thought is that you set "_id" as your primary key in your base model, but the service returns you "id"
Update : adding sample normal behavior code:
var UserModel = Backbone.Model.extend({ idAttribute: '_id', url: '/api/user', defaults: { username: '' } }); user = new UserModel({_id : 20}); user.save(); user = new UserModel(); user.save();
Output: PUT / api / user 405 (method not allowed) POST / api / user 404 (not found)
Check how the first instance of the model has an identifier, and it is trying to execute PUT, but a different POST. I cannot reproduce your problem, so I believe that the problem is related to your server response.
Daniel Aranda
source share