Skip to content

Commit

Permalink
use set / get for Ids
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonkneen committed Feb 23, 2018
1 parent 2997b9e commit dc87828
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions reste.js
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ var main = function() {

} else if ( model instanceof Backbone.Model) {

if (model.id && method == "create") {
if (model.get("id") && method == "create") {
method = "update";
}

Expand All @@ -534,7 +534,7 @@ var main = function() {
}

// update!
params[modelConfig.id] = model.id;
params[modelConfig.id] = model.get("id");

params.body = params.body || model.toJSON();

Expand Down Expand Up @@ -568,8 +568,8 @@ var main = function() {

if (model[modelConfig.id]) {
options[modelConfig.id] = model[modelConfig.id];
} else if (model.id) {
options[modelConfig.id] = model.id;
} else if (model.get("id")) {
options[modelConfig.id] = model.get("id");
}

options.error ? onError = function(e) {
Expand Down Expand Up @@ -625,6 +625,7 @@ var main = function() {
} else {
// otherwise pass to success
e.id = e[modelConfig.id];
model.set("id", e[modelConfig.id]);
options.success(e);
}
}, onError);
Expand All @@ -634,7 +635,7 @@ var main = function() {

body = {};

body[modelConfig.id] = model.id;
body[modelConfig.id] = model.get("id");
body.body = model.toJSON();

// change to change the attributes before sending
Expand Down

0 comments on commit dc87828

Please sign in to comment.