My model looks like the following right now:
window.List = Backbone.Model.extend({
title: null,
idAttribute : '_id',
url : function() {
return "/list/" + this.id + ".json";
}
});
I’m tweaking my api to respond differently to become more response to formats. This works great for fetching an existing record, but when it tries to create a new one it obviously attempts to post to ‘/list/undefined.json’. Is there a way I can tell if the model is new and is going to be saved for the first time, or would it be a better idea to perhaps look at the request body to determine if it’s text/json?
Your Backbone.Model instances have a function
isNew(). When this is true, it means it has never been saved to the server.