Reputation: 637
i have created model, view and collections in different js file and i am loading all files using require.js data insertion is performed but when i am editing or deleting data it will not performed and while editing data instead of sending PUT request it will send POST request and new data is inserted. may be the model instance is not get connected with view.
I am using nodejs for server side rendering and backbonejs for client side rendering. my templates having a .html extension n using ejs view engine.
Upvotes: 0
Views: 320
Reputation: 5703
When you POST new data to create an object, does your rest route respond with an ID? Your model will be looking for a JSON response from the successful create call. All you really need is ID, but any can include any other info you would like to be set on the model.
All you would really need to respond with is a 201 Created and { "id": "NzIdHda" }
If Backbone models do not have an ID, they will always POST and try and create new. Once they get an ID (either on instantiation or as the result of a .save(), they will no longer consider themselves "new".
Upvotes: 1