model.save and json object
Hi, i have start using your plugin and i have some questions
when i do model.save(), i see that no parameters are send in the request. so i have saved the model this: this.model.save({param:this.model.toJSON()})
my question is there any other technique which i can use to send the parameters as an json object?
EDIT:
Hello, hope you can help.
I'm using your backbone.rpc plugin and probably i'm doing something wrong. each time i save the model i get duplication in my backbone model. i have the regular model properties as well as the param object that contains the model properties.
I'm using this like so:
method deceleration in model: create: ['saveCampaign', 'params'],
save method: this.model.save({params:that.model.toJSON()});
what exactly i'm doing wrong?, how can i save the backbone.model, without seting each property like you have on your git example. hope you can help
Thanks
I'm having the same issue as you. Hoping a solution arises.
Hi Derek, I had to "hack" the plugin to work with regular object, i would have shared my version of it, but its really!! ugly hack, its actually quite simple to write your sync method instead of modify the plugin.
any way if you need something simple, and just want to make an RPC call, here is a blueprint:
var that = this;
$.ajax({
contentType: "application/json; charset=utf-8",
type: 'POST',
dataType: 'json',
url: "/rpc",
data: JSON.stringify({
jsonrpc: '2.0',
method: "namespace." + that.url,
id: String((new Date()).getTime()),
params: [that.toJSON()]
}),
success: function(data) {
},
error: function(data) {
}
});
best.
The project looks for a maintainer, but if anyone wants to send in the PR, I´m happy to merge, test & release it.