Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

model.save and json object #12

Open
saniko opened this issue Jan 16, 2013 · 3 comments
Open

model.save and json object #12

saniko opened this issue Jan 16, 2013 · 3 comments
Assignees
Labels

Comments

@saniko
Copy link

saniko commented Jan 16, 2013

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

@ghost ghost assigned asciidisco Feb 2, 2013
@newsomderek
Copy link

I'm having the same issue as you. Hoping a solution arises.

@saniko
Copy link
Author

saniko commented May 22, 2013

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.

@asciidisco
Copy link
Owner

The project looks for a maintainer, but if anyone wants to send in the PR, I´m happy to merge, test & release it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants