Backbone model.save() is sending PUT instead of POST
You can specify the ID in defaults, just make sure it's set to null
(isNew will be set to true).
In your case it must be
LineNo_: null
The above answers are correct in that if the model
you are .save
'ing has an id
attribute backbone will do a PUT
rather than a POST
.
This behavior can be overridden simply by adding type: 'POST'
to your save block:
var fooModel = new Backbone.Model({ id: 1});
fooModel.save(null, {
type: 'POST'
});
ID should not even exist for a new entry. The issue is in the part you didn't show - in the part where you instantiate, create and populate the model.
Here is a quote from the Backbone documentation:
If the model does not yet have an
id
, it is considered to be new.
It is clear from your code that you are assigning an id attribute.
Your backend should be doing that.
And since you are doing it on a client, backbone presumes it it not new, and uses PUT