javascript - How to make can.Model send JSON data when update? -
i have code:
var sotriesmodel = can.model.extend({ findall: 'get /api/stories/', create: function(story) { console.log(story) return $.ajax({ url: '/api/stories/', type: 'post', contenttype: "application/json; charset=utf-8", datatype: "json", data: json.stringify(story) }); }, update : function(story) { console.log(story) return $.ajax({ url: '/api/stories/', type: 'put', contenttype: "application/json; charset=utf-8", datatype: "json", data: json.stringify(story) }); }, destroy: 'delete /api/stories/{id}' }, {}); var story = new sotriesmodel({id:123123, name:"test"}); story.save();
what expect save put request json in payload, id number:
123123
the update method signature using function can.model.update: function(id, serialized) -> can.deffered
.
so first parameter id , second serialized data.
changing update : function(story) {}
update : function(id, story) {}
should solve problem.
Comments
Post a Comment