javascript - Backbone model.save() sends attributes to the server in a weird way -
i have backbone , set attributes this:
comment.set({ commentable_id: 1, commentable_type: "post", body: "comment body", parent_id: 123, blabla: 'blabla' }); then, when seek save this:
comment.save({}, {[callbacks here]}); it sends info server this:
{"commentable_id"=>"1", "commentable_type"=>"post", "parent_id"=>"123", "blabla"=>"blabla", "body"=>"comment body" "comment"=> {"body"=>"comment body", "commentable_id"=>"1", "commentable_type"=>"post"}} so, can see, info duplicated within comment key, not all. need attribtues within comment key , none outside of it.
the backbone model absolutely empty:
app.models.comment = backbone.model.extend({ urlroot: '/comments', initialize: function() { }, }); what doing wrong here?
could avoid set , utilize save directly?
comment.save({ comment: { commentable_id: 1, commentable_type: "post", body: "comment body", parent_id: 123, blabla: "blabla" } }); javascript backbone.js
No comments:
Post a Comment